简体   繁体   English

IIS:无法获得高吞吐量

[英]IIS: Unable to get high throughput

I have a IIS app; 我有一个IIS应用程序; 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. 在尝试解决此问题时,我们进行了测试-加载测试页面,该页面返回约1000字节的静态数据,并且控制器处于休眠状态。 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. 我们发现,如果睡眠持续时间大约为1秒,则IIS无法在1秒内处理超过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? 现在,我了解了并发请求以及.Net 4.5之后的版本,默认值为5000。因此,如果IIS处理5000个并发请求,为什么它不能以10 rps的速度处理请求,而每个请求却要花1秒钟? 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. 因此,没有任何机器参数(如CPU,磁盘,网络等)超过限制。 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; 那里的视图返回一些静态HTML。 I created the web app using Visual Studio template; 我使用Visual Studio模板创建了Web应用程序; the template returns static HTML. 模板返回静态HTML。

When I remove the sleep, then I have no problem running the server at high rps. 当我消除睡眠时,那么以高rps运行服务器就没有问题。 But then the requests complete so fast, that IIS would not even be encountering any high concurrency at even high rps. 但是随后请求完成得如此之快,以至于IIS甚至在高rps时都不会遇到任何高并发性。

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会话不是线程安全的,并且您不能有来自同一会话的并行请求。 ASP.NET will simply serialize the calls and execute them sequentially. ASP.NET将简单地序列化调用并按顺序执行。 This results in the blocking that you're seeing when you call Thread.Sleep() . 这将导致您在调用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" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM