gpt4 book ai didi

c# - IIS 服务器上的 CPU 在 BufferAllocator.GetBuffer() 中固定为 100%

转载 作者:行者123 更新时间:2023-11-30 22:13:25 25 4
gpt4 key购买 nike

我有一个处理大量 RESTful 请求的 IIS7 应用程序池。当事情变热时,CPU 使用率达到 100%,请求需要很长时间才能处理。

在使用 ANTS 进行分析时,我们发现大部分 CPU 时间通常都花在了这里:

System.Web.Hosting.PipelineRuntime.ProcessRequestNotification
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper
(Unmanaged code)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper
System.Web.HttpRuntime.ProcessRequestNotificationPrivate
System.Web.HttpApplication.BeginProcessRequestNotification
System.Web.HttpApplication+PipelineStepManager.ResumeSteps
System.Web.HttpApplication.ExecuteStep
System.Web.HttpApplication+CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute
System.Web.HttpResponse.FilterOutput
System.Web.HttpWriter.FilterIntegrated
System.Web.Hosting.IIS7WorkerRequest.GetBufferedResponseChunks
System.Web.Hosting.RecyclableArrayHelper.GetIntegerArray
>> System.Web.BufferAllocator.GetBuffer
(Thread blocked)
>> System.Web.BufferAllocator.ReuseBuffer
(Thread blocked)

实际上有几种不同的堆栈跟踪,但它们总是以 GetBuffer()ReuseBuffer() 结尾。

GetBuffer()ReuseBuffer() 都以 lock() 开头,所以我认为 CPU 花费了大量时间自旋锁(我的理解是 lock 在让线程休眠之前自旋了一点)。

我的问题 - 这是 CPU 花费时间的常见位置吗?这完全在 IIS 代码中,那么我可以做些什么来减少 CPU 负载呢?这是配置问题,还是我们的应用程序之前执行的操作的结果?

这些机器非常强大,它们有 4 个四核。我没有当前可用的线程数。

最佳答案

这几乎就是我们所怀疑的 - 线程都在自旋锁中花费了大量的时间,因为它们都在争夺同一个锁。我们有数百个线程。

修复是用更少的线程拥有更多的进程 - 现在 CPU 使用率是合理的。

关于c# - IIS 服务器上的 CPU 在 BufferAllocator.GetBuffer() 中固定为 100%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19164866/

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