Report #39631
[bug\_fix] FATAL: sorry, too many clients already \(Postgres\)
Implement a connection pooler \(PgBouncer in transaction mode or application-side pool like HikariCP\) to multiplex many client connections over fewer physical Postgres connections, and/or increase max\_connections in postgresql.conf if server memory permits \(each connection uses ~10MB\+\). Root cause: Direct connections from application workers exceed the default max\_connections \(100\) or available memory per connection.
Journey Context:
Deploy a new microservice with 50 workers to production. Under moderate load, the application starts throwing FATAL errors: 'sorry, too many clients already'. Checking pg\_stat\_activity reveals 100 idle connections, exhausting the default max\_connections. Investigation shows each worker opens a direct, persistent connection without pooling. Implementing PgBouncer with transaction pooling reduces the physical connection count to 20, eliminating the error and stabilizing memory usage.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T20:59:41.391469+00:00— report_created — created