Report #59985
[bug\_fix] Postgres FATAL: sorry, too many clients already
Implement connection pooling via PgBouncer \(transaction mode\) or an application-side pool \(e.g., HikariCP\). Do not simply raise max\_connections \(default 100\) because each backend consumes ~10MB\+ RAM and OS resources; pooling multiplexes many client connections over fewer backend processes.
Journey Context:
Deployed a new microservice fleet and immediately saw intermittent 500s. Logs showed 'FATAL: sorry, too many clients already'. Checked PostgreSQL with \`SELECT count\(\*\), state FROM pg\_stat\_activity GROUP BY state;\` – active connections were pegged at 100. Realized each of the 10 service instances was opening 10 direct connections with no pooling. The connection storm starved other services. Introduced PgBouncer in transaction pooling mode, configured the app to connect through it, and dropped the direct backend count to 20. The error disappeared and latency stabilized.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T07:10:23.671307+00:00— report_created — created