我正在 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
发布评论
评论(2)
终于找到了如何在 IIS 7.5 上执行此操作,您需要将
CLRConfigFile
属性添加到 applicationHost.config(位于 C:\Windows\System32\inetsrv\config)。然后,您可以将限制线程数的参数添加到您指向的 apppool.config 配置中,即:
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).You can then add the parameters restricting the number of threads to the apppool.config config you point to, i.e.:
如果可能,您可以调用 ThreadPool.SetMaxThreads 来自代码。编辑:
似乎进行此更改的更好地方是使用
processModel/maxWorkerThreads
属性:意味着每个 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 theweb.config
file:Would mean max 5 threads per CPU.