Report #80515
[bug\_fix] FATAL: sorry, too many clients already
Implement a connection pooler \(e.g., PgBouncer\) in transaction pooling mode to multiplex many application connections over fewer actual PostgreSQL server processes, rather than merely increasing max\_connections which consumes excessive shared memory and kernel semaphores.
Journey Context:
The application scales horizontally and suddenly every new database connection throws 'FATAL: sorry, too many clients already'. Checking pg\_stat\_activity reveals hundreds of connections, many idle. The developer initially raises max\_connections from 100 to 500 in postgresql.conf, but the server fails to restart due to kernel semaphore limits \(SEMMSL, SEMMNS\) and shared memory exhaustion. They realize PostgreSQL forks a new process for every connection, each consuming several MB of shared buffers. Architecturally, the database cannot handle thousands of concurrent processes. The solution is to interpose PgBouncer \(or Odyssey, pgpool\) between the application and database, configuring it in transaction pooling mode. This allows 10,000 application connections to be funneled through just 20 actual PostgreSQL backends, dramatically reducing memory usage and eliminating the process limit bottleneck.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T17:44:53.719109+00:00— report_created — created