3

Server Specs: IIS 7.5, Windows Server 2008 R2 (Version 6.1), ASP.NET 4.5 Runtime

We are having issues with hanging requests. When we poll the iis server for long running requests, we see the following results below.

REQUEST "6600000080001fd7" (url:GET /, time:180821 msec, client:10.2.2.7, stage:AcquireRequestState, module:Session)
REQUEST "81000000800034da" (url:POST /url1.aspx, time:8101709 msec, client:10.2.2.7, stage:AcquireRequestState, module:Session)
REQUEST "d600000080001e84" (url:POST /url2.aspx, time:8095609 msec, client:10.2.2.7, stage:AcquireRequestState, module:Session)
REQUEST "c800000080001d31" (url:POST /url3.aspx, time:7494459 msec, client:10.2.2.7, stage:AcquireRequestState, module:Session)
REQUEST "8700000080001e69" (url:GET  /url4.aspx, time:7474179 msec, client:10.2.2.7, stage:AcquireRequestState, module:Session)
REQUEST "ac00000080001ddd" (url:GET  /url5.aspx, time:7472338 msec, client:10.2.2.7, stage:AcquireRequestState, module:Session)

These hung requests happen 10-100 times per day on our app. It started happening after a major app rev which had many page updates. We upgraded the framework from 4.0 to 4.5 as well.

How do I further debug or prevent requests from hanging?

User perspective

For the user, they make a request, and it never comes back. Since the requests are session stacked, their application freezes and they must clear their cookies before they can access the application again.

Additional Info.

We are using a seperate state server for session management. Specs Windows server 2008 R2 with asp.net runtime 4.5.

Community
  • 1
  • 1
monkeyhouse
  • 2,875
  • 3
  • 27
  • 42
  • Since the request are blocked at the `AquireRequestState`, the reason is most likely caused by Asp.Net's *one concurrent request per session* feature. See at the bottom of [this page](https://msdn.microsoft.com/en-us/library/ms178581.aspx). You probably have one request **executing** for a *long* time, causing other requests to be blocked until it finishes. You need to find which long running request is executing and blocking the other request. – user1429080 Jan 12 '17 at 15:01
  • @user1429080 I would agree, but the blocking long running requests should show up at a stage other than ```AcquireRequestState``` All our long running requests show the same stage. – monkeyhouse Jan 12 '17 at 15:27
  • And what kind of session state mode are you using? InProc? Something else? – user1429080 Jan 12 '17 at 15:37
  • We are using an internal state server `````` ( normal config as far as I can tell ) – monkeyhouse Jan 12 '17 at 15:44
  • Ok. You mention upgrading to .Net 4.5. Do you use Async in the upgraded version? Could it be that you have a deadlock? See (for instance) [here](http://stackoverflow.com/a/15022170/1429080) – user1429080 Jan 12 '17 at 18:03
  • That's a very reasonable question, but we didn't add any async/await code. We're going to do a bit more failed request tracing and then bump to 4.6 as a flail attempt in case somehow this hotfix didn't get rolled into the version of 4.5 we have https://support.microsoft.com/en-us/kb/2828841 – monkeyhouse Jan 12 '17 at 19:05

1 Answers1

3

In ASP.NET Sessions are not thread safe. This means that you cannot have 2 concurrent requests to the same endpoint from the same session. Thus if you have a long running request that depends on the session state, it will cause all other concurrent requests from this same session to block until the request finishes. This behavior is even more visible when making for example several AJAX requests to the server because they are all from the same session. That's one of the reasons why absolutely never use ASP.NET SessionState in my applications -> it just can't scale by design.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928