We've been having this problem with an MVC application for a few weeks now. Every now and then the site will hang. Resource monitor would show the app using a large amount of threads (above 100). A quick peek to the database (SQL Server) revealed that for each of those threads there is also a connection that is doing absolutely nothing (and has never actually run any query at all). We looked through the hanging requests and there are some 100 legit page requests. We've been looking through those requests in search for a some error, but those pages all seem to work normally and the problem seems difficult to recreate. Edit: We didn't look carefully enough, the answer was there. To sum it up:
- app runs normally
- something bad happens that causes connections to database to do nothing, but still allows to make them
- because of this normal requests to the site are never completed and make the app run out of resources (connections in connection pool and worker threads); this doesn't go away until the app is restarted (or better yet app pool recycled, as restarting the app doesn't kill the hanged threads)
Does anyone have an idea what could be causing this behavior? The problem might (or might not) be in our code, but so far it has proven to be extremely difficult to pinpoint. Any clues are most welcome.