Report #9030
[bug\_fix] FATAL: sorry, too many clients already
Implement a external connection pooler \(PgBouncer or pgpool in transaction pooling mode\) or reduce the application's pool size to fit within max\_connections. Do not simply raise max\_connections above a few hundred without increasing shared\_buffers and kernel SHMMAX, as each connection consumes significant backend memory \(~5-10MB\).
Journey Context:
A Node.js API using node-postgres with a pool size of 20 per instance scales horizontally to 10 pods, hitting the default max\_connections of 100. Intermittent 500s appear with FATAL errors in Postgres logs. Investigation with pg\_stat\_activity shows 100 idle connections, all from the app, with no active queries. Realizing each pod creates its own pool, the math \(10 × 20 = 200\) exceeds the limit. The solution is introducing PgBouncer in transaction mode between the apps and Postgres, allowing hundreds of client connections to multiplex through a small pool of actual Postgres backends.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T07:10:34.955222+00:00— report_created — created