Web apps & software

What is connection pooling?

Connection pooling keeps a limited set of database connections open and hands them out to requests as needed, because opening a fresh connection for every request is slow and databases can only hold so many at once.

The failure it prevents

A traffic spike brings 800 simultaneous requests. Without a pool, the app tries to open 800 connections, the database refuses with "too many connections," and the site returns errors. With a pool capped at 40, extra requests wait briefly for a free connection and the database stays healthy.

Where pools live

Most application frameworks include one. PgBouncer and ProxySQL sit between app and database as separate poolers. Serverless functions are a special danger: each short-lived instance may open its own connection, so use a pooling proxy or a data API.

Settings to review

  • Maximum pool size, kept below the database limit across all app servers combined.
  • Timeout for waiting on a free connection.
  • Idle connection lifetime, since firewalls may silently drop quiet connections. A leak, where code forgets to return a connection, shows up as a pool that slowly empties until everything hangs.

Questions, answered

No. Past a point, extra connections compete for the same CPU and disk and slow the database.

When many app instances or serverless functions connect, a pooler is often worth it.

By the Stegnor team · Updated