Managing connections efficiently.
WHAT A POOL IS
A set of connections reused across requests.
WHY IT EXISTS
Establishing a connection is expensive relative to a query.
WHAT SIZE TO USE
Far smaller than most people assume.
WHY
Concurrency beyond what the database can process causes contention, not throughput.
WHAT DETERMINES A SENSIBLE SIZE
Processor cores and disk capability, rather than expected users.
WHAT TO MEASURE
Whether connections are waiting, and whether the database is saturated.
WHAT TO SET
A maximum lifetime, so connections are recycled An idle timeout A connection test, so dead connections are not handed out
WHY DEAD CONNECTIONS MATTER
A restarted database leaves the pool holding useless handles.
WHAT THE SYMPTOM IS
Errors immediately after a database restart, resolving on their own.
WHAT TO BE CAREFUL WITH
Several application servers each with a large pool.
WHY
The total is what reaches the database, and it is easy to exceed the limit.
WHAT TO CALCULATE
Servers multiplied by pool size, against the server limit.
WHAT TO LEAVE HEADROOM FOR
Administrative connections.
WHY
Being unable to connect to diagnose a problem is a bad position.
WHAT TO RESERVE
A small number of connections for administrative use.