Connection Pooling Best Practices
pgbouncer, RDS Proxy.
Overview
Connection pooling best practices use connection pools correctly. Picking a pool is the easy decision; misuse (wrong size, wrong mode, no isolation) produces incidents that the pool was supposed to prevent.
- pgbouncer or RDS Proxy. Two main choices; pgbouncer for control, RDS Proxy for AWS-managed simplicity.
- Pool size. Per-application pool size; matches DB capacity; sized too high starves the DB, too low queues the app.
- Transaction mode. Per-pool mode (session, transaction, statement); transaction is the right default.
- Idle timeout plus per-tenant. Per-pool idle timeout reclaims unused; per-tenant pool isolation supports multi-tenant.
The approach
The practical approach: right pool size based on DB capacity, transaction mode by default, monitored pool state, per-tenant separation, documented configuration. The team’s discipline produces healthy pools.
- Right pool size. Per-application size matches DB
max_connectionsdivided by app count; leaves headroom for migrations. - Transaction mode. Per-pool transaction mode for most workloads; supports highest connection reuse.
- Monitor pool state. Per-pool utilisation; the metric that warns before connection-wait latency spikes.
- Per-tenant separation. Per-tenant pool isolation; one tenant’s exhaustion does not starve the others.
- Document the configuration. Per-pool rationale committed to the repo; supports operational reviews.
Why this compounds
Pool discipline compounds across services. Each correctly-sized pool produces ongoing reliability; the team’s database expertise grows; new services ship with right-sized pools.
- Better resilience. Right pool size avoids exhaustion; the user never sees "no connections available."
- Better resource utilisation. Pool reuse reduces handshake cost; the steady-state DB load drops.
- Better operational fit. Right mode matches workload; transaction mode unlocks reuse where session mode prevents it.
- Institutional knowledge. Each pool teaches connection patterns; the team’s database engineering muscle grows.
Pool discipline is an operational discipline that pays off across years. Nova AI Ops integrates with database telemetry, surfaces patterns, and supports the team’s database engineering discipline.