Report #11056
[architecture] Database connection pool exhaustion under load
Size connection pools using Little's Law: connections = \(latency × throughput\). Measure average request latency \(seconds\) × peak throughput \(requests/sec\) to get the minimum concurrent connections needed; cap at \(core\_count × 2\) \+ effective\_spindle\_count for Postgres, or use 'minimum idle' in HikariCP to avoid cold start latency.
Journey Context:
The default pool size in many frameworks \(10, 20, or 100\) is arbitrary. Devs often think 'more connections = more throughput' but databases use one thread per connection \(Postgres\) or have lock contention \(MySQL InnoDB\). Beyond CPU core count, context switching kills performance. The 'magic formula' from Postgres experts is: pool\_size = \(core\_count × 2\) \+ effective\_spindle\_count \(for disk I/O\). However, for app servers with high latency to DB \(network RTT\), Little's Law dominates: if your app handles 1000 req/s and each query takes 10ms, you need 10 concurrent connections minimum. Use an 'minimum idle' setting to keep warm connections ready but don't exceed the DB's max\_connections \(shared across all app instances\!\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T12:20:50.877866+00:00— report_created — created