I am getting the below error from my .net application.
Source: xxx.Services.xxx.xxx.xxxx.xxxx.xxxxRequest --- System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.InvalidOperationException: 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.
I have seen several posts regarding this connection pool error.I have gone through most of it and i understand why it is happening and the possible solutions from on the application side like closing the connections opened by application. These is what i understood :
- Opened connections are not closed, called connection leaking.
- Morethan 100 concurrent connections are being used. Increase the max pool size in the connection string if we have more than 100 simultaneous users.
- Slow queries or open transactions blocks new connections. When the connections are being held open by slow query execution/open transactions and instead of being reusing connections the new connection are open and eventually reaches the connection pool maximum.
How can i monitor this from the database side.I saw some suggestions like use sp_who or sp_who2 to see the existing sessions.When i execute sp_who2 when i see these errors,i see lots of active sessions,but how can i see the connection pool information and the connections which comes under the pool. Questions:
- Is there any way to track the connections opened and relate it to a connection pool created from database side.
I have noticed that when the issue happens,the queries which normally runs faster ,goes slow.
- Is it expected?Because i am suspecting whether the slow queries are causing the connection pool errors.