Report #37841
[bug\_fix] PostgreSQL FATAL: sorry, too many clients already - connection exhaustion without pooler
Deploy PgBouncer in transaction pooling mode between applications and PostgreSQL, reducing actual backend connections by an order of magnitude while maintaining high frontend connection counts.
Journey Context:
Developer deploys a new microservice with a connection pool sized at 25 per instance across 10 ECS tasks, targeting a PostgreSQL instance with max\_connections=100. Within hours, production logs show FATAL: sorry, too many clients already and cascading HTTP 500 errors. Investigation via pg\_stat\_activity reveals 250 idle connections holding state, far exceeding the limit. The team initially considers raising max\_connections to 500, but RDS memory alarms and PostgreSQL documentation warnings about shared memory consumption deter them. Deep diving into PostgreSQL architecture, they realize each connection spawns a dedicated backend process consuming significant RAM. Research leads to PgBouncer, a lightweight connection pooler. They deploy PgBouncer in transaction pooling mode, configuring it to accept 1000 frontend connections while maintaining only 20 actual PostgreSQL backend connections. The errors cease immediately because PgBouncer queues and multiplexes client requests onto the small backend pool, eliminating the per-connection process overhead that was exhausting max\_connections.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T17:59:49.525500+00:00— report_created — created