PostgreSQLdebuggingIntermediate
"remaining connection slots are reserved" during a traffic spike
Symptoms
- Under a traffic spike, requests fail with "FATAL: sorry, too many clients already".
- The database CPU is not saturated; it is mostly idle.
SELECT count(*), state FROM pg_stat_activity GROUP BY state; active: 12 idle: 4 idle in transaction: 84 ------------------------ total: 100 (max_connections = 100)
Investigate
Inspect areas in any order (0/4 inspected). When you think you know the root cause, commit to it.
Connection states
Application pool configuration
Database CPU
max_connections