debugMajorpending
PostgreSQL connection pool exhaustion -- too many clients
Viewed 0 times
too many clientsconnection poolPgBouncermax_connectionsidle timeoutpooler
postgresqlnodejspython
Error Messages
Problem
Application stops responding with 'too many clients already' or connection timeouts. Database has hit max_connections limit. Adding more app instances makes it worse.
Solution
(1) Use a connection pooler: PgBouncer (most common) or pgcat in front of PostgreSQL. Transaction pooling mode reuses connections across requests. (2) Reduce pool size per app instance: 5-10 connections is usually enough per instance, not 20-50. (3) Close idle connections: set idle_in_transaction_session_timeout. (4) Monitor: SELECT count(*) FROM pg_stat_activity. (5) For serverless: use Neon pooler, Supabase pooler, or RDS Proxy. Default max_connections is 100 -- shared across ALL clients.
Why
Each PostgreSQL connection uses ~10MB of memory and a process. Connection pooling multiplexes many app connections over few database connections.
Revisions (0)
No revisions yet.