Tuesday, February 14, 2012

Connection sleeping

If an MS SQL 2005 Connection is sleeping in the activity monitor, does it mean it's not closed? I'm pretty sure it's closed, just want to confirm.

Lately, our DB server got hammered with requests and it reached max-pool size (we implemented caching after that).

On MS SQL 2005 if you close the connection, you'll see it as sleeping waiting for you to open a new connection, when you do that MS SQL 2005 will give you one of those sleeping connections. Make sure all connections are close on your end.|||

I have not found this to be true. I have a method which opens a connection, runs a SQL statement, then closes the connection. If I cal this method quickly, hundreds of times (such as in a loop), then I spawn hundreds of connections (which all appear to be sleeping) and the pool size is exceeded and everything locks up. There do not appear to be any connection leaks (the .Close() method is always called).

The very interesting thing is that this only happens in IIS -- it does not happen in Casini (the "built-in" ASP.NET server within Visual Studio). In Casini the connections seem to be handled much better -- this tells me it is not a SQL Server issue but may be an IIS connection pool handling issue.

Does anyone have any thoughts?

Thanks everyone,

Matt

No comments:

Post a Comment