Report #90058
[bug\_fix] Postgres FATAL: sorry, too many clients already \(SQLSTATE 53300\)
Implement PgBouncer in transaction pooling mode between application and Postgres, or reduce application-side connection pool sizes. Root cause: Postgres uses a process-per-connection model; each backend consumes significant shared memory \(catalog caches, work\_mem maintenance\), and the default max\_connections \(100\) or hardware limits are hit when app servers collectively open too many direct connections.
Journey Context:
Deployed new microservice \(Node.js with TypeORM\) to production alongside existing 5 services. Within hours, database connections spiked and new requests failed with 'sorry, too many clients already'. Checked Amazon RDS metrics: 'Maximum used connections' flatlined at 100 \(default max\_connections\). Investigated pg\_stat\_activity: hundreds of idle connections from different service pods. Realized each of the 10 Node.js instances used a connection pool size of 20, totaling 200 desired connections against a 100 limit. Considered increasing max\_connections to 200, but AWS RDS db.t3.medium has limited memory and shared\_buffers would be insufficient. Decided to introduce PgBouncer as a sidecar in transaction pooling mode, reducing actual Postgres connections to 50 while app still thinks it has 200.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T09:45:33.042645+00:00— report_created — created