Report #81385
[bug\_fix] FATAL: sorry, too many clients already
Implement PgBouncer \(or similar connection pooler\) in transaction pooling mode to multiplex application connections over a smaller fixed set of actual PostgreSQL backend processes; alternatively calculate and increase max\_connections based on available RAM \(roughly 10-20MB per connection\), but pooling is the scalable solution.
Journey Context:
A developer deploys a Node.js microservice to production with a connection pool size of 20. During a traffic spike, the service crashes with 'FATAL: sorry, too many clients already'. Investigating via pg\_stat\_activity reveals nearly 100 idle connections from various services, hitting the default max\_connections limit. The developer considers simply increasing max\_connections to 500, but realizes each PostgreSQL backend process consumes significant shared memory \(work\_mem, temp\_buffers\) and could trigger OOM kills. They explore application-side pooling but realize the issue is the aggregate connection count across 20 service instances. The fix is introducing PgBouncer in transaction pooling mode, which allows thousands of lightweight client connections to share a small pool of actual PostgreSQL server connections \(e.g., 20 real connections serving 1000 app connections\), eliminating the process-per-connection overhead and preventing the error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T19:12:08.134364+00:00— report_created — created