The last few days we see this error message in our website too much:
"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."
We have not changed anything in our code in a while. I revised the code to check open connections which didn't close, but found everything to be fine.
How can I solve this?
Do I need to edit this pool?
How can I edit this pool's max number of connections?
What is the recommended value for a high traffic website?
Update:
Do I need to edit something in IIS?
Update:
I found that the number of active connections are anywhere from 15 to 31, and I found that the max allowed number of connections configured in SQL server is more than 3200 connections, is 31 too many or should I edit something in the ASP.NET configration?
This is mainly due to the connection not been closed in the application. Use "MinPoolSize" and "MaxPoolSize" in the connection string.
You have leaked connections on your code. You may try to use using to certify that you're closing them.
https://blogs.msdn.microsoft.com/angelsb/2004/08/25/connection-pooling-and-the-timeout-expired-exception-faq/
You can try that too, for solve timeout problem:
If you didn't add httpRuntime to your webconfig, add that in
<system.web>
tagand
Modify your connection string like this;
At last use
You can specify minimum and maximum pool size by specifying
MinPoolSize=xyz
and/orMaxPoolSize=xyz
in the connection string. This cause of the problem could be a different thing however.I have encountered this problem too, when using some 3rd party data layer in one of my .NET applications. The problem was that the layer did not close the connections properly.
We threw out the layer and created one ourselves, which always closes and disposes the connections. Since then we don't get the error anymore.
Unless your usage went up a lot, it seems unlikely that there is just a backlog of work. IMO, the most likely option is that something is using connections and not releasing them promptly. Are you sure you are using
using
in all cases? Or (through whatever mechanism) releasing the connections?