Report #8290
[bug\_fix] FATAL: sorry, too many clients already
Implement a connection pooler \(PgBouncer in transaction mode\) or drastically reduce per-instance connection pools. Root cause: Postgres forks a process per connection consuming ~10-20MB RAM; without external pooling, application servers \(Node.js/Python workers\) exhaust the low default max\_connections \(100\). PgBouncer multiplexes N application connections over M actual Postgres backends \(M << N\), preventing process starvation.
Journey Context:
Traffic spikes trigger cascading connection failures. Logs show FATAL errors. Developer increases RDS max\_connections to 500 but soon hits memory limits and Ulimits. Checking \`pg\_stat\_activity\` reveals 200 idle connections from 20 Kubernetes pods, each with pool size 10. Realizes math doesn't scale: 50 pods × 10 connections = 500, but burst traffic creates connection storms during deployments. Attempts to use PgBouncer but initially configures it in session mode, which doesn't reduce backend count. Finally switches to transaction pooling, reducing 400 idle app connections to 20 actual Postgres backends.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T05:10:25.188718+00:00— report_created — created