Connection Leak: Why SQL Server Connections Only Climb

Connection Leak: Why SQL Server Connections Only Climb

Nobody will say it out loud, but the pattern is familiar. Early in the week the connection count sits at a few hundred. By Friday it is past a thousand, the pool starts timing out, and someone recycles the app pool and the count falls straight back. The workload never changed.

How do I tell whether a connection leak is making my SQL Server connection count climb? A connection leak shows up as the daily low point of your connection count rising while the workload stays flat, then dropping at every app pool recycle or restart. Compare the lowest hourly peak of each day against batch requests or CPU. A floor growing 5 percent a day with flat activity means a likely leak.

Database Health Monitor has a report built for exactly this shape, and it answers the question with a verdict instead of a hunch. Here is why the obvious chart misleads you, and what to look at instead.

Connection Leak Detector is one of the reports in Database Health Monitor. It runs against your own servers, and it takes about a minute to have this same screen open on one of them.

Why a connection count chart lies

Plot the connection count and you get peaks. Peaks rise whenever load does: a month end report, a sale, a bad plan that makes every request slower. So a rising peak proves nothing. You end up arguing with the app team over a line that has three plausible explanations.

Connections Over Time is good at showing those peaks and the hour of day profile. It does not test for a trend that is independent of the workload, and it does not find the cycles. That is a different question.

Measure the floor of each cycle

The honest number is the lowest point of the day. Load can push a peak up, but at the quietest hour of the day an app that closes its connections returns to roughly the same place. If the quiet hour keeps getting higher, sessions are being left behind.

The report works from a peak per hour. A cycle starts when an hour falls more than 30 percent below the highest of the three hours before it and the next three hours stay low. A dip that bounces straight back is ignored. For each cycle longer than a day, the floor is the lowest hourly peak of each day, and a day needs at least 12 hourly samples to count.

The slope is a Theil-Sen slope, the median of the slopes between every pair of days, so one strange Tuesday cannot drag it. The same slope is taken for an activity proxy. That is batch requests per second when the instance hosts the history database, and SQL CPU otherwise.

VerdictWhat it means
Leak likelyFloor grows at least 5 percent a day, activity moves by no more than 2 percent a day
Grows with loadFloor grows at least 5 percent a day and activity grows by more than 2 percent a day
FlatFloor grows by less than 5 percent a day
Too shortCycle is a day or less, or has under two full days of samples

The headline also reports the recycle rhythm, such as every 7 days, once two complete cycles are similar in length. If the floor is climbing, it estimates the days until it reaches 32,767, the user connection ceiling, when that falls within a year.

Find the connection leak on screen

The chart draws the hourly peak as a thin blue line, the daily floor as a heavy red line, and the activity proxy as a dotted green line on the right axis. A dashed vertical line marks each cycle boundary. Red climbing while green stays flat is the leak.

The grid has one row per cycle, newest first. It gives start, end, days, what started it, the floor at each end, both slopes and the verdict. The trigger reads Restart when the Availability SLA record shows an outage ending at that time, and Recycle otherwise.

It reads only DBHealthHistory, so it opens even when the monitored instance is down. Historic Monitoring has to be configured first, or the page says Historic connection not configured. The default window is 40 days because the rollup rounds values after that and keeps one peak per day after 100 days.

History cannot name the guilty program, because Workload by Application records only sessions that did work. Live sessions asks the instance directly. It groups sessions by program, host and login, counts those idle over an hour, and shows the oldest login. The program with the most idle sessions is your suspect.

The usual caveat applies. Connections counts every user session, idle or not, so a growing user base looks like a leak until you check the verdict. Grows with load is the page telling you that. The full reference lives in the Connection Leak Detector documentation.

If your trouble is waiting rather than piling up, the same history database powers Find the Head Blocker Behind a Month of Blocking and Memory Grant Waits: Find the Queries That Queued. A leak and a queue often arrive in the same bad week.

What to check on your own server

  • Open the history window at 40 days and read the headline for a rise in connections per day
  • Compare the floor slope with the activity slope for each cycle in the grid
  • Check whether the cycle boundaries line up with app pool recycles or a Restart entry
  • Run Live sessions and note the program with the most sessions idle over an hour

Try Database Health Monitor Today

Connection Leak Detector tells you whether your connection count climbs without more work behind it, and which program holds the idle sessions. Database Health Monitor shows it on every instance you connect, in the time it takes to open the report.

Download Database Health Monitor and run the Connection Leak Detector report against your own server. There is nothing to configure first, and you will know inside a few minutes whether it tells you something you did not already know.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

To prove you are not a robot: *