Fixed-size pre-warmed pool vs dynamic on-demand pooling for bursty SQL Server workloads
0 reputation · 26 Mar 2020, 07:22 UTC
0 reputation · 26 Mar 2020, 07:22 UTC
Design choice is between a fixed-size pre-warmed pool using Min Pool Size and a dynamic on-demand pool with Min Pool Size at zero for a workload with high-concurrency bursts followed by idle periods.
Connection pooling is managed client-side by the ADO.NET provider, not by the SQL Server engine. Pool behavior is governed by Max Pool Size and Min Pool Size in the connection string. A fixed-size pre-warmed approach aims to eliminate connection establishment latency during spikes. A dynamic approach aims to reduce resource consumption on the database during idle periods.
Uncertainty remains about the interaction of Min Pool Size with connection lifetime and pool exhaustion under intermittent load.
What is the documented retention behavior of connections when Min Pool Size is set above zero during idle intervals? How does pool growth toward Max Pool Size behave when concurrent requests arrive faster than connections are returned? Under what conditions does the pooler reuse versus discard idle connections?
35275 reputation · 26 Mar 2020, 14:42 UTC
When Min Pool Size is set above zero, the ADO.NET connection pooler retains at least that many open connections after they are first created. Idle connections are not closed by the pooler due to inactivity alone; they remain in the pool until the application domain unloads, the process exits, or ClearPool/ClearAllPools is called.
Max Pool Size is synchronous and blocking: if all pooled connections are in use and a new request arrives, the pooler creates a new connection on the calling thread (up to Max Pool Size). Under a burst where requests arrive faster than connections are returned, callers wait on the pool’s internal semaphore and experience connection‑establishment latency for each new connection until Max Pool Size is reached.GetConnection or via the background health check, (b) Connection Lifetime (seconds) is set and exceeded at the moment the connection is returned to the pool, or (c) the pool is cleared explicitly. There is no background timer that proactively shrinks the pool down to Min Pool Size.Min Pool Size to the expected baseline (e.g., 5) and pre‑warm by opening and closing that many connections at startup.Max Pool Size to a value that your SQL Server can sustain (consider worker threads, login rate, and licensing). Avoid setting it arbitrarily high without server‑side capacity planning.Connection Lifetime at 0 (infinite) unless you have a reason to recycle connections; otherwise, a non‑zero lifetime combined with Min Pool Size > 0 can cause the pool to oscillate and defeat pre‑warming.sys.dm_exec_sessions) during idle to verify it matches Min Pool Size per pool.If you observe unexpected latency or pool exhaustion, please provide the current Max Pool Size value and any observed wait times (e.g., from ETW PoolGet events) so we can determine whether the client pool or SQL Server resources are the bottleneck.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.