Timeout expired obtaining connection from pool under concurrent load in VB.NET ASP.NET Core
0 reputation · 20 Dec 2020, 23:40 UTC
Connection pool saturation with default settings
An ASP.NET Core service written in VB.NET uses Microsoft.Data.SqlClient with the default connection pool (maximum 100 connections). Under sustained concurrent request volume, callers block on synchronous ADO.NET methods such as ExecuteReader and Open instead of their asynchronous counterparts. This blocks thread-pool threads, delays connection release, and eventually triggers a SqlException with the message "Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool."
Unresolved sizing versus async adoption trade-off
The framework does not auto-scale the pool; Max Pool Size must be increased explicitly in the connection string. However, raising the limit without eliminating blocking callers shifts contention to the database server (connection limits, worker threads, lock contention). Conversely, converting all callers to await OpenAsync() and await ExecuteReaderAsync() may not suffice if upstream middleware or filters still block on .Result or .Wait(). Connection leaks from missing Using/Await Using further reduce available slots non-deterministically.
What criteria should guide the decision between increasing Max Pool Size versus enforcing a fully asynchronous call chain when both approaches carry downstream resource risks?