I'm investigating this error from a MVC3 application that is failing under load:
"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."
The application is using the Repository pattern and Entity Framework, and my hunch is that it's not closing off connections properly. I want to be able to monitor the number of pooled connections on the SQL Server. Searching around leads me to believe that I can use these counters in Perfmon:
However both of them show and being disabled / grayed out.
I am running Perfmon directly on the server, and both ISS and SQL Server are running on the server. Any ideas why these counters would not be available?
I've also tried using SQL Profiler to monitor pooled connections, but the EventSubClass column isn't available for AuditLogin.
The Microsoft Windows Performance Monitor is a tool that administrators can use to examine how programs running on their computers affect the computer's performance. The tool can be used in real time and also be used to collect information in a log to analyze the data at a later time.
While database connection pooling can help improve application performance, it's not a one-size-fits-all solution. Depending on the specifics, it may not be a solution at all.
Right-click on the top-level object for a SQL Server connection, and select Activity Monitor.
You can run this from a SQL query windows to get a count and the details of current connections and session running on your SQL server.
select * FROM sys.dm_exec_sessions AS es
INNER JOIN sys.dm_exec_connections AS ec
ON es.session_id = ec.session_id
I've had trouble with pooled connections. They're hard to control. Explicitly closing them never seemed to work since they're under the control of .NET. The biggest reason we've run out of connections is uncommitted transactions. If a transaction is left uncommitted or rolled back for some reason, the connection, instead of being re-used, get's stuck in limbo, forcing .NET to open yet another connection to continue processing.
From the SQL side, the only viable way to review this is by setting up a login event trace. The "Event Subclass" column will tell you if the event happened using a pooled connection or not. With that, you can correlate the host, login, and application names and continue digging.
Audit Login Event Class
On the application side you can use the performance counters of ".NET DATA PROVIDER FOR SQL SERVER" on perfmon.
Performance Counters in ADO.NET
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With