Report #76287
[bug\_fix] FATAL: sorry, too many clients already \(Postgres connection exhaustion\)
Implement a connection pooler \(PgBouncer in transaction mode or RDS Proxy\) between applications and Postgres, or reduce per-instance pool size so that \(app\_instances × pool\_size\) < max\_connections \(default 100\). Root cause: Postgres spawns a backend process per connection; without pooling, microservices exhaust the finite backend slots, causing kernel-level connection refusal.
Journey Context:
Deploying a Node.js microservice with 20 pods, each using a connection pool of 10, immediately saturates a managed Postgres with max\_connections=100. Errors spike with FATAL: sorry, too many clients. Checking pg\_stat\_activity reveals 200\+ idle connections from previous pods that weren't properly closed during rolling updates. Initial attempt to increase max\_connections to 200 fails because kernel shmmax is too low. The realisation hits that persistent TCP connections from a K8s pod pool don't scale linearly. Introducing PgBouncer in sidecar mode with transaction pooling reduces actual backend connections to 20, while each Node.js instance thinks it has 10 dedicated connections.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T10:38:46.503489+00:00— report_created — created