Report #35208
[bug\_fix] Postgres FATAL: sorry, too many clients already
Introduce an external connection pooler \(PgBouncer in transaction mode\) to multiplex application connections, or reduce per-instance connection counts. Raising max\_connections is discouraged without kernel shmmax adjustments as it risks OOM.
Journey Context:
During a production rollout, the app suddenly returns 500s. Logs reveal FATAL: sorry, too many clients already. Checking pg\_stat\_activity shows 100 active connections, matching SHOW max\_connections. The microservice architecture spawns 15 instances, each with a connection pool of 10, exhausting the limit. Increasing max\_connections to 200 is rejected by the kernel due to shmmax limits. Instead, PgBouncer is deployed in transaction mode between the apps and Postgres, multiplexing thousands of app-side connections onto a stable pool of 20 actual Postgres backends, eliminating the error and reducing memory pressure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T13:33:55.500371+00:00— report_created — created