Report #93544
[bug\_fix] FATAL: sorry, too many clients already
Implement a connection pooler \(PgBouncer or pgpool\) in transaction pooling mode to multiplex many application connections over fewer actual Postgres connections, rather than simply raising max\_connections which risks shared memory exhaustion.
Journey Context:
Intermittent 500s started appearing in the web tier. Logs revealed "FATAL: sorry, too many clients already". Checking pg\_stat\_activity showed hundreds of idle connections, one per app worker. With 50 app servers each running 20 workers, they quickly exhausted the default max\_connections \(100\). Initially considered raising max\_connections to 1000, but the Postgres docs warn that each connection consumes shared memory and OS resources, risking OOM. The debugging shifted to architecture: direct connections don't scale. Implemented PgBouncer in transaction pooling mode between the apps and Postgres. This multiplexes hundreds of app connections over ~20 actual database connections, eliminating the error entirely while keeping resource usage flat.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:36:06.470525+00:00— report_created — created