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?
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