gpt4 book ai didi

c# - MaxConcurrentRequestsPerCPU 和 MaxConcurrentThreadsPerCPU 没有按照记录工作?

转载 作者:太空宇宙 更新时间:2023-11-03 16:14:21 27 4
gpt4 key购买 nike

在 IIS7.5 环境中,我配置了 aspnet.config 以将 MaxConcurrentRequestsPerCPU 设置为 1。

我正在 IIS 的这个实例上执行一个 Web 服务,我已为其配置公开 MaxConcurrentRequestsPerCPU 和 MaxConcurrentThreadsPerCPU 以响应 ASMX Web 服务中的 WebMethod,这允许我通过 Web 服务确认 .NET 框架是正确读取这些值,因此 IIS 应该通过简单地让 WebMethod 从 HostingEnvironment 对象返回值来正确使用它们。

我还有一个 WebMethod,它简单地将线程休眠 5 秒,简称为 TestMethod。

理论上,我认为此设置应确保后续调用 TestMethod 以串行方式发生,因为每个 CPU 只允许 1 个请求,或者,如果每个 CPU 实际上允许在四核系统上的每个内核,最多并行处理 4 个请求,具体取决于它是真正针对每个 CPU 还是每个内核。

然而,这两种情况似乎都不是。对于此方法的 20 个同时请求,我希望看到大约 100 秒(20 个请求 x 5 秒)或 25 秒((20 个请求/4 个核心)x 5 秒)的完成时间。相反,我始终以 10 秒的完成时间结束,这意味着尽管并发请求限制设置为 1,但仍在并行处理 10 个请求。当我还将每个 CPU 的并发线程也设置为 1 时,情况仍然如此。

谁能解释为什么这些设置似乎被忽略了,或者在这种情况下似乎没有像记录的那样工作?

最佳答案

要对此进行测试(这是一个非常奇怪的测试,任何人都不应该在生产中做这样的事情)您需要将 maxConcurrentRequestsPerCPU 设置为 1,然后将 MaxConcurrentThreadsPerCpu 设置为 0。

原因是 ThreadsPerCpu 设置是为了模拟老式 IIS 限制(“经典”应用程序池模式)。

There is a corresponding IIS 7.5 change (Windows Server 2008 R2 only) which allows different aspnet.config files to be specified for each application pool (this change has not been ported to IIS 7.0). With this, you can configure each application pool differently. The maxConcurrentRequestsPerCPU setting is the same as the registry key described above, except that the setting in aspnet.config will override the registry key value. The maxConcurrentThreadsPerCPU setting is new, and allows concurrency to be gated by the number of threads, similar to the way it was done in Classic/ISAPI mode. By default maxConcurrentThreadsPerCPU is disabled (has a value of 0), in favor of gating concurrency by the number of requests, primarily because maxConcurrentRequestsPerCPU performs better (gating the number of threads is more complicated/costly to implement). Normally you'll use request gating, but you now have the option of disabling it (set maxConccurrentRequestsPerCPU=0) and enabling maxConccurentThreadsPerCPU instead. You can also enable both request and thread gating at the same time, and ASP.NET will ensure both requirements are met. The requestQueueLimit setting is the same as processModel/requestQueueLimit, except that the setting in aspnet.config will override the machine.config setting. All of this may be a little confusing, but for nearly everyone, my recommendation is that for ASP.NET 2.0 you should use the same settings as the defaults in ASP.NET v4.0; that is, set maxConcurrentRequestsPerCPU = "5000" and maxConcurrentThreadsPerCPU="0".

http://blogs.msdn.com/b/tmarq/archive/2007/07/21/asp-net-thread-usage-on-iis-7-0-and-6-0.aspx

关于c# - MaxConcurrentRequestsPerCPU 和 MaxConcurrentThreadsPerCPU 没有按照记录工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16167893/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com