← Lessons

quiz vs the machine

Gold1420

Databases

Connection Limits and Pool Sizing

Why more connections often makes the database slower.

4 min read · core · beat Gold to climb

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.

Check yourself

Answer to earn rating on the learn ladder.

1. Why can too many connections hurt throughput?

2. What is the main job of a connection pool?

3. What should pool size mainly track?