Static pool_size vs. aggressive queue_timeout for transient spikes
0 reputation · 15 Jul 2024, 03:16 UTC
Managing database connection pools in Elixir via Ecto and DBConnection requires balancing application responsiveness against database server resource limits. When a system experiences sudden, short-lived concurrency spikes, the pool can become exhausted, leaving processes to wait in the queue.
One approach is to increase the pool_size to accommodate peak loads, which reduces queuing but consumes more memory and process slots on the database server. Alternatively, maintaining a conservative pool size while implementing a strict queue_target and short timeout forces a fail-fast mechanism to prevent request piling and linear latency growth.
Given a constraint where database server RAM is limited, but application availability must be maintained during transient bursts:
- Does increasing the pool size provide better stability than a fail-fast queue strategy when the database is the primary bottleneck?
- At what threshold does the risk of database-side resource exhaustion outweigh the benefit of reduced application-side queuing?