Databases · interactive
Connection pooling
Every Postgres connection is a process using memory, so the database caps them with max_connections. A pooler sits in front with two more limits: how many app connections it accepts, and how many real connections its pool opens. Pick a platform, then change any number and see which limit breaks first.
8 instances × 10 connections → PgBouncer
1 · App connections into PgBouncer (client limit 100)
2 · Server connections the app needs (pool size 20, one per connected client)
3 · Postgres max_connections = 100
- Queries failing
- 75%
- Wait per query
- 120 s, then error
- Queued
- 60
- Limit hit
- pool size
What you'd see
- app: Queries hang, then fail after 120 s: query_wait_timeout (default 120 s)
; pgbouncer.ini pool_mode = session max_client_conn = 100 default_pool_size = 20 -- postgresql.conf max_connections = 100
80 connections each hold a server connection for their whole session, but the pool has 20. The rest wait until the timeout, then fail.
Platform
Defaults: max_client_conn = 100, default_pool_size = 20, pool_mode = session. The pool is per user + database pair.
Pool mode
Database and pooler limits
Your app
Driver or ORM
new Pool(): max defaults to 10.
1 2 3 How many real connections the pooler opens per user + database. In session mode each client keeps one for its whole session, so the pool must be as big as the client count. In transaction mode only in-flight transactions need one.
Failure: queries queue, then time out.
4
In production
Tools and technologies
Poolers sit between apps and Postgres in most production setups.
Not tied to one language — use these names when you search docs or design a system.
- PgBouncerSoftware
Lightweight Postgres connection pooler.
Official site ↗ - Amazon RDS ProxyService
Managed pooling for RDS and Aurora.
Official site ↗ - SupavisorSoftware
Supabase's pooler; limits come with the compute size.
Documentation ↗ - Neon poolingService
PgBouncer in transaction mode, up to 10,000 clients.
Documentation ↗ - HikariCPSoftware
The standard JVM connection pool.
GitHub ↗