Connection Limits
"FATAL: too many connections for role" — and then the scramble starts.
PostgreSQL's default max_connections is 100. Each connection uses ~5-10MB of RAM. But the real cost isn't memory — it's lock contention and process scheduling overhead at high connection counts.
Rules of thumb:
- Don't set max_connections above 200-300 without a connection pooler
- Use PgBouncer or Supavisor in front of PostgreSQL
- Set your application pool size to (CPU cores * 2) + effective_spindle_count
- Monitor idle connections — they consume resources while doing nothing
```sql
SELECT state, count(*)
FROM pg_stat_activity
GROUP BY state;
```
If "idle" connections outnumber "active" by 10:1, you need a connection pooler, not a higher max_connections.
Mydba.dev can help you keep track of these connections automatically along with everything else you need to know.













