Plainnotes

Connections exhausted: look here before adding hardware

2025-07-23 · 2 min readDeploy

too many connections usually triggers a max_connections bump, but three causes matter more.

Oversized pools: twenty connections per instance across ten instances is two hundred, which no small database enjoys. Size the total against cores — roughly cores * 2 + spindles — with headroom.

Slow queries holding slots: look for state = 'active' with an old query_start in pg_stat_activity.

idle in transaction: the application opened a transaction and then called an external service. The connection is held and so are locks. This one is the most hidden and the most damaging.

Order: kill long transactions, fix slow queries, and only then consider parameters. Raising max_connections multiplies per-connection memory and can take the database down.