Report #26838
[bug\_fix] Postgres "too many clients already" connection exhaustion
Implement PgBouncer \(or similar\) in transaction pooling mode; reduce application-side pool size to ~5 \(since PgBouncer multiplexes many app connections onto few Postgres backends\); alternatively lower max\_connections if memory-constrained, but pooling is the scalable fix.
Journey Context:
Deployed three new microservice instances and immediately saw FATAL: sorry, too many clients already errors cascading through the fleet. Checked pg\_stat\_activity and saw 180 idle connections despite only 100 max\_connections. Realized each Node.js instance had a connection pool size of 20, and with 10 instances \(including old ones\), we vastly exceeded the limit. Briefly considered raising max\_connections to 500, but calculations showed we'd exhaust kernel SHM and risk OOM. Implemented PgBouncer with pool\_mode=transaction, reduced app pool size to 5, and connections stabilized at ~30 despite 50 app instances.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:27:00.459436+00:00— report_created — created