Connections Are Not Free
Each database connection consumes memory and a server side worker. Past a point, adding connections does not add throughput because the real bottleneck is CPU cores and disk, and extra connections just fight over them.
The Pool
A connection pool keeps a fixed set of open connections that application requests borrow and return. This caps concurrency, avoids the cost of opening a connection per request, and protects the database from a flood of clients.
Sizing the Pool
- A pool that is too small leaves requests waiting in the queue.
- A pool that is too large causes context switching and lock contention that lowers throughput.
- A common starting point ties pool size to the number of cores plus the count of disks, not to the number of users.
Measure under load and tune. The goal is enough connections to keep cores busy, not one per concurrent user.
Key idea
A connection pool caps concurrency so the database is not overwhelmed, and the right size is bounded by cores and disks rather than by the number of users.