Report #51011
[bug\_fix] FATAL: sorry, too many clients already \(SQLSTATE 53300\)
Implement a connection pooler \(e.g., PgBouncer or pgpool\) in transaction-pooling mode rather than simply raising max\_connections, which only defers the problem and risks OOM due to per-connection memory overhead \(work\_mem, etc.\).
Journey Context:
An application deployed on Kubernetes with 50 pods horizontally scaled suddenly throws 500s. Logs reveal FATAL: sorry, too many clients already. The DBA checks pg\_stat\_activity and sees 200 idle connections from app pods, exceeding the default max\_connections of 100. The initial fix attempt raises max\_connections to 500 in postgresql.conf and restarts. During the next traffic spike, the OS kills the Postgres process with OOM-killer because each connection consumes backend memory. The team realizes Postgres uses a process-per-connection model and that the correct architecture is to introduce PgBouncer as a sidecar or separate service, configured in transaction pooling mode. This allows 1000 logical app connections to multiplex into 20 actual Postgres connections. The error disappears, memory usage stays flat, and the app scales horizontally without connection exhaustion.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T16:06:10.819697+00:00— report_created — created