Blog Post

SQL: The timeout period elapsed prior to obtaining a connection from the pool

Friday, August 19, 2016 3:29 AM

I have experienced this exception and took mi some time to figure out what was wrong.

Details of the exception

Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.  


The solution:

We have to update max pool size to allow multiple connections. Be aware that too many pools can lead to decreased performance. We will update our connection string by adding Max Pool Size=200; 

<add name="DefaultContext" providerName="System.Data.SqlClient" connectionString="Data Source=ServerName;Max Pool Size=200;" />

App Pool

A connection pool is created for each unique connection string. When a pool is created, multiple connection objects are created and added to the pool so that the minimum pool size requirement is satisfied. Connections are added to the pool as needed, up to the maximum pool size specified (100 is the default). Connections are released back into the pool when they are closed or disposed.

 

For more information about pools : https://msdn.microsoft.com/en-us/library/8xx3tyca(v=vs.110).aspx