使用 IIS 7.5 限制每个处理器的线程数

发布于 2024-09-18 14:13:31 字数 311 浏览 6 评论 0 原文

我正在 ASP.NET MVC 应用程序上运行一些性能测试。我看到争用率很高,并且线程数量随着时间的推移而增加。我相信两者是相关的,因为线程被阻塞,线程池会创建新线程来处理传入的请求。我相信这反过来又会使争用变得更糟(即更多线程更多争用)。

正确的方法可能是找出争用的原因,即缩小关键部分,验证是否确实需要所有锁等。但是,作为一个间歇步骤,我想限制可以创建的线程数通过线程池。我相信,尽管这可能会导致请求在队列中停留的时间更长,但它会整体改善,因为它会减少争用和线程上下文切换。

但是,我可以找到如何在 IIS 7.5 中配置它,有人可以帮助我吗?

谢谢, 抢

I’m running some performance tests on an ASP.NET MVC application. I see a high contention rate and the number of threads increasing overtime. I believe the two to be related, as threads are blocked new threads are created by the thread pool to handle incoming requests. I believe this in turn is making the contention worse (i.e. more threads more contention).

The correct approach is probably to take the cause of the contention, i.e. make the critical sections smaller, verify that all the locks are really needed etc. However, as an intermitted step I’d like to limit the number of threads that can be created by the thread pool. My belief is that all though this may lead to requests staying in the queue longer it will improve overall though put as it will reduce contention and thread context switching.

However, I can find how to configure this in IIS 7.5, can anyone help me?

Thanks,
Rob

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

划一舟意中人 2024-09-25 14:13:31

终于找到了如何在 IIS 7.5 上执行此操作,您需要将 CLRConfigFile 属性添加到 applicationHost.config(位于 C:\Windows\System32\inetsrv\config)。

    <add name="ASP.NET v4.0" CLRConfigFile="C:\code\ThreadLeakWebSite\apppool.config" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" />

然后,您可以将限制线程数的参数添加到您指向的 apppool.config 配置中,即:

<configuration>
    <system.web>
        <applicationPool maxConcurrentRequestsPerCPU="5000" maxConcurrentThreadsPerCPU="0" requestQueueLimit="5000"/>
    </system.web>
</configuration>

Did finally find how to do this on IIS 7.5 you need to add a CLRConfigFile attribute to the applicationHost.config (located in C:\Windows\System32\inetsrv\config).

    <add name="ASP.NET v4.0" CLRConfigFile="C:\code\ThreadLeakWebSite\apppool.config" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" />

You can then add the parameters restricting the number of threads to the apppool.config config you point to, i.e.:

<configuration>
    <system.web>
        <applicationPool maxConcurrentRequestsPerCPU="5000" maxConcurrentThreadsPerCPU="0" requestQueueLimit="5000"/>
    </system.web>
</configuration>
巨坚强 2024-09-25 14:13:31

如果可能,您可以调用 ThreadPool.SetMaxThreads 来自代码。

编辑:

似乎进行此更改的更好地方是使用 processModel/maxWorkerThreads 属性:

<configuration>
  <system.web>
    <processModel maxWorkerThreads="5"/>
...

意味着每个 CPU 最多 5 个线程。

If possible, you could call ThreadPool.SetMaxThreads from code.

EDIT:

It seems a better place to make this change would be with the processModel/maxWorkerThreads property in the web.config file:

<configuration>
  <system.web>
    <processModel maxWorkerThreads="5"/>
...

Would mean max 5 threads per CPU.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文