Connection pooling reuses a fixed set of established database connections instead of opening one for every query or request. Establishing a connection requires a TCP handshake and authentication, adding roughly 20–50 ms each time; at high request rates, that cost compounds. A shared pooler can serve requests from multiple application instances through common open connections. section 5.4.3
Pooling is primarily a scalability control, not a universal response-time fix. It limits connection contention as concurrency rises, while query optimization addresses slow individual queries and resilience patterns address dependency failures. For PostgreSQL, connection counts matter especially because each connection creates a dedicated operating-system process; MySQL and SQL Server use lighter-weight threads. section 5.1 section 5.4.3
Size a pool by balancing queueing against database capacity:
- Count total possible connections across all application servers, not only the size configured on one server. section 5.4.3
- Treat too few connections as a latency risk: requests queue when no connection is available, affecting p99 latency. section 5.4.3
- Treat too many connections as a database-capacity risk: PostgreSQL degrades when many backend processes consume memory and contend for CPU. section 5.4.3
- Target 50–70% normal utilization for headroom; investigate sustained utilization above 80% by evaluating database capacity or reducing query latency. section 5.4.3
Estimating shared capacity
Ten application servers with pools of 20 expose 200 potential database connections. With 10 ms average queries, each connection can theoretically serve 100 queries per second, or 20,000 queries per second across the pool. Leave headroom rather than designing around that theoretical maximum, because workload variance raises utilization and queueing. section 5.4.3
Startup behavior is part of pool design. Eager initialization establishes connections before service readiness and can fail fast when the database is unreachable. Lazy initialization starts the pool while acquiring connections in the background, so connections open on first use. Pre-warming opens a minimum number immediately and creates remaining connections lazily, trading faster startup against immediate traffic readiness. section 5.3.1
Monitor pool metrics during development and under load: active connections, idle connections, and requests waiting for a connection. Use those signals to size for expected concurrency and alert when the pool approaches exhaustion. Auditing peak connection counts and utilization links configuration to observed database stability and application latency. section 7.2.2 section 5.4.4










