0

I have a IIS app; during load testing of our app we found the throughput to be very low. While trying to fix the problem, we ran a test - load testing a page that returns some 1000 bytes of static data, with a sleep in the controller. What we find is that if the sleep duration is something like 1 second, IIS is unable to serve requests, within 1 second, at loads exceeding something like 10 rps.

Now I read about the Concurrent Requests and how post .Net 4.5, the default value is 5000. So if IIS is handling 5000 concurrent requests, how come it is unable to serve requests at 10 rps, with each request taking 1 second? Maths does not add up.

Notice that static data is returned, data size is small, and all the function doing is to sleep. So none of the machine params like CPU, disk, network etc go over limit. The server hardly blinks.

This is the entire controller code

public ActionResult Contact()
{
    Thread.Sleep(1000);
    return View();
}

The view in there returns some static HTML; I created the web app using Visual Studio template; the template returns static HTML.

When I remove the sleep, then I have no problem running the server at high rps. But then the requests complete so fast, that IIS would not even be encountering any high concurrency at even high rps.

Amit
  • 1,836
  • 15
  • 24

1 Answers1

0

Do all of the requests belong to the same session? If so, this post indicates the cause of the issue.

Essentially, it turns out that the ASP.NET session is not thread safe and you cannot have parallel requests from the same session. ASP.NET will simply serialize the calls and execute them sequentially. This results in the blocking that you're seeing when you call Thread.Sleep().

If the requests come from different sessions, there should be no blocking. In any case, you can try turining off the sessions:

<sessionState mode="Off" />
Community
  • 1
  • 1
Connor
  • 807
  • 1
  • 10
  • 20
  • I have a simple C# load test program HttpWebResponse objWebResponse = (HttpWebResponse)objRequest.GetResponse(); Which is called from multiple threads to get the desired load. No explicit session creation. Would that result in same session on IIS? Since I am not sending back any session information, I guess not. – Amit Oct 18 '16 at 12:40
  • Unless otherwise specified, there is a session ID that is sent back as a cookie in the response. If subsequent requests send that cookie along, ASP.NET will treat them all as being part of the same session. It would be worth a shot to try turning the session state off and see if that works in your case. – Connor Oct 18 '16 at 13:49
  • I will try that; but we are NOT sending back cookies through that load generator. – Amit Oct 19 '16 at 08:22