Max Pool Size exhaustion behavior and diagnostic counter reliability
0 reputation · 04 Oct 2024, 03:48 UTC
Goal: Determine the exact moment when a SqlClient connection pool that has reached its Max Pool Size begins to queue new requests versus throwing a timeout exception, and whether the .NET Data Provider for SqlServer performance counters (NumberOfActiveConnections, NumberOfPooledConnections) reliably indicate this state before any exception is raised.
Constraints: Assume the default Max Pool Size of 100, a standard connection timeout, and a scenario where SqlConnection instances are opened but not disposed, creating a leak. Uncertainty remains about whether ClearPool or ClearAllPools can affect in‑use connections and thus mask the leak, and whether monitoring the counters provides a safe early‑warning window.
- At what pool utilization percentage does SqlClient switch from granting connections immediately to queuing them?
- Does calling ClearPool on a pool that has exhausted its Max Pool Size release any in‑use connections, or only idle ones?
- Can the NumberOfActiveConnections counter be trusted to signal exhaustion early enough to prevent timeout exceptions?