Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens when a connection pool is exhausted?

I'm reading about SQLAlchemy's connection pooling, which has a default of 5 connections and will by default overflow to 10.

If the number of cached connections is exceeded, what happens? Are subsequent requests queued until a free connection becomes available or will a new connection that doesn't enter the pool be created?

Also, what happens to unused connections when the pool has "overflowed" to its default max of 10? Do those connections disconnect after the default time (as with the standard pool), or are they released more aggressively than the standard pool?

like image 349
Matty Avatar asked Apr 03 '12 18:04

Matty


People also ask

What is connection pool exhaustion?

The error message occurs because Platform Analytics cannot connect to the database from the connection pool. To solve this issue, set a higher number of concurrent maximum active database connections from the connection pool.

What happens when connection pool is full?

If the maximum pool size has been reached and no usable connection is available, the request is queued. The pooler then tries to reclaim any connections until the time-out is reached (the default is 15 seconds). If the pooler cannot satisfy the request before the connection times out, an exception is thrown.

What is connection pool issue?

The point of the connection pool is to keep a connection ready for the next call because creating connections is expensive. The connection objects maintained by the pool are backed by actual database connections, and the database is the one who closes that actual connection after the idle timeout period.

Why is connection pool important?

Using connection pools helps to both alleviate connection management overhead and decrease development tasks for data access. Each time an application attempts to access a backend store (such as a database), it requires resources to create, maintain, and release a connection to that datastore.


1 Answers

You are reading about the QueuePool, which manages database connections for better performance. It does this by holding open idle connections, in case you want to reuse them later. The number of connections it will hold open is pool_size=5 (default). If you open a sixth connection, one of the connections in the queue will be closed, as long as it is idle. If none are idle, the QueuePool will open additional ones, upto max_overflow=10 (default). Any more and you will get an error. However both of these parameters are configurable. Set pool_size=0 to have unlimited open connections. The source is here

like image 67
Riaz Rizvi Avatar answered Oct 08 '22 16:10

Riaz Rizvi