Connection pool: establishing a TCP and authentication handshake per query is slow. A pool keeps a fixed number of connections open and lends them out, dramatically reducing latency under load.
2 / 5
What happens during pool exhaustion?
Pool exhaustion: when demand exceeds the maximum pool size, callers queue. Long-running or leaked connections worsen this. Tuning the max size and query timeouts prevents cascading stalls.
3 / 5
What is a connection leak?
Connection leak: code that forgets to close or release a connection keeps it checked out forever. Over time the pool empties. Using try-with-resources or context managers ensures release even on error.
4 / 5
Why might you place a pooler like PgBouncer in front of PostgreSQL?
External pooler: PostgreSQL spawns a process per connection, which is memory-heavy. PgBouncer in transaction mode lets thousands of clients share a few dozen real backend connections.
5 / 5
What does the idle timeout setting of a pool control?
Idle timeout: connections sitting unused are eventually closed so the pool shrinks during quiet periods. Setting it too low causes churn; too high wastes database slots that could serve other clients.