A pool keeps database connections open and reuses them instead of reconnecting on every request (connecting is slow and databases have a maximum number of connections).
Key settings: pool_size, max_overflow, pool timeout and pool_pre_ping (detects dead connections); total connections = workers x (pool_size + max_overflow), which must stay under the database limit across all instances.
With many replicas use an external pooler such as PgBouncer, and always release sessions (the yield dependency does this) to prevent pool exhaustion.
Loading…