Report #27077
[bug\_fix] FATAL: sorry, too many clients already \(SQLSTATE 53300\)
Deploy PgBouncer \(or similar\) in transaction pooling mode between applications and Postgres, reducing physical connections to a small fixed pool \(e.g., 20\), while application connection pools are sized to account for total pod count. Root cause: Postgres creates a backend process per connection; microservices with many pods exhaust max\_connections without a centralized pooler.
Journey Context:
A developer deploys a Node.js microservice to Kubernetes with 50 pods, each configured with a pg-pool max size of 20. During a rolling update, they see intermittent 500s with 'FATAL: sorry, too many clients already'. They check pg\_stat\_activity and see 100 idle connections, hitting the default max\_connections=100. They attempt to increase max\_connections to 500, but Postgres warns about shared memory exhaustion. They analyze the math: 50 pods × 20 connections = 1000 potential connections, far exceeding any safe max\_connections value. They realize each pod restart leaves connections in TIME\_WAIT or idle in Postgres, exacerbating the issue during deploys. Searching for solutions, they find that PgBouncer in transaction mode maintains a small pool of actual Postgres connections \(e.g., 20\) while allowing the application to think it has many logical connections. After inserting PgBouncer between the app and Postgres and reducing per-pod pool sizes to 5, the 'too many clients' errors disappear completely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:50:52.824425+00:00— report_created — created