在ASP.NET MVC4 Web应用程序上,w3wp的CPU使用率上升到100% [英] CPU usage of w3wp rises to 100% on a ASP.NET MVC4 web application
问题描述
我们有一个使用Entity Framework 4.0的ASP.NET MVC4应用程序.当我们在生产服务器上部署时,CPU会在一段时间(约2-5小时)后升高,直到接近100%.内存也将上升,直到达到最大值.一段时间后,由于内存过多,应用程序池将自动重置.
We have a ASP.NET MVC4 application which uses Entity Framework 4.0. When we deploy on the production server, the CPU rises after some time (~2-5h) until nearly 100%. The memory also rises then until maximum. After a while the application pool will be resetted automatically because of the high memory.
服务器:Windows 2008 R2 Standard SP1 IIS:7(V 7.5.7600.16385) 只有一个应用程序池和一个Web应用程序正在运行.
Server: Windows 2008 R2 Standard SP1 IIS: 7 (V 7.5.7600.16385) Only one application pool and one webapplication is running.
消耗大量CPU的线程的调试诊断工具中的Stacktrace:
Stacktrace from Debug Diagnostic Tool of the thread which consumes most of the CPU:
SNIReadSyncOverAsync(SNI_ConnWrapper*, SNI_Packet**, Int32)
.SNIReadSyncOverAsync(SNI_ConnWrapper*, SNI_Packet**, Int32)
System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr, System.Web.RequestNotificationStatus ByRef)
System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr, System.Web.RequestNotificationStatus ByRef)
ntdll!NtWaitForSingleObject
KERNELBASE!WaitForSingleObjectEx
System_Data!SNIReadSyncOverAsync
System_Data_ni!load_config_used
System_Data_ni!load_config_used
System_Data_ni!load_config_used
System_Data_ni!load_config_used
System_Data_ni!load_config_used
System_Data_ni!load_config_used
System_Data_ni!load_config_used
System_Data_ni!load_config_used
System_Data_ni!load_config_used
System_Data_ni!load_config_used
System_Data_ni!load_config_used
System_Data_ni!load_config_used
System_Data_ni!load_config_used
System_Data_ni!load_config_used
System_Data_ni!load_config_used
System_Data_Entity_ni
System_Data_Entity_ni
System_Data_Entity_ni
System_Data_Entity_ni
System_Core_ni
System_Core_ni
0x000007fe`99223112
0x000007fe`99222a88
0x000007fe`99222899
0x000007fe`992205cb
0x000007fe`99355596
System_Web_Mvc_ni+138058
System_Web_Mvc_ni+13ca67
System_Web_Mvc_ni+13e71c
System_Web_Mvc_ni+13ca03
System_Web_Mvc_ni+13d175
System_Web_Mvc_ni+13cbe9
System_Web_Mvc_ni+1431df
System_Web_Mvc_ni+13dade
System_Web_Mvc_ni+14f5fe
System_Web_Mvc_ni+13b0ef
System_Web_Mvc_ni+14f514
System_Web_ni
System_Web_ni
System_Web_ni
System_Web_ni
System_Web_ni
System_Web_ni
System_Web_ni
System_Web_ni
clr!UMThunkStub
webengine4!W3_MGD_HANDLER::ProcessNotification
webengine4!W3_MGD_HANDLER::DoWork
webengine4!RequestDoWork
webengine4!CMgdEngHttpModule::OnExecuteRequestHandler
iiscore!NOTIFICATION_CONTEXT::RequestDoWork
iiscore!NOTIFICATION_CONTEXT::CallModulesInternal
iiscore!NOTIFICATION_CONTEXT::CallModules
iiscore!W3_CONTEXT::DoWork
iiscore!W3_CONTEXT::IndicateCompletion
webengine4!MgdIndicateCompletion
System_Web_ni
System_Web_ni
System_Web_ni
System_Web_ni
clr!UM2MThunk_WrapperHelper
clr!UM2MThunk_Wrapper
clr!Thread::DoADCallBack
clr!UM2MDoADCallBack
clr!UMThunkStub
webengine4!W3_MGD_HANDLER::ProcessNotification
webengine4!ProcessNotificationCallback
clr!UnManagedPerAppDomainTPCount::DispatchWorkItem
clr!ThreadpoolMgr::ExecuteWorkRequest
clr!ThreadpoolMgr::WorkerThreadStart
clr!Thread::intermediateThreadProc
kernel32!BaseThreadInitThunk
ntdll!RtlUserThreadStart
您知道这个CPU上升的原因是什么吗?
Have you an idea what is the reason of this CPU rising?
推荐答案
嘿,使用大量线程时间,我在SNIReadSyncOverAsync
上遇到了完全相同的问题(我是使用DebugDiag发现的).
Hey I had the exact same issue with SNIReadSyncOverAsync
using a significant amount of thread time (I discovered this using DebugDiag).
我不知道这是否对其他人有帮助,但是看来我们的问题出在我们所使用的Azure DB服务器上.我们将其设置为仅50个DTU,最多具有100个并发请求.
I don't know if this will help anyone else but it looks like our problem was with the Azure DB server we were using. We had it set to only 50 DTUs, which has a maximum of 100 concurrent requests.
基本上SNIReadSyncOverAsync
很大,因为Web服务器必须坐在那里等待DB服务器的响应,并且DB服务器一次只能处理100个请求,因此Web服务器最终要等待很长时间(导致100%的CPU使用率和无法访问的网站).这可能会随着最近网络访问量的增加而弹出(例如:如果你们最近购买了广告,并且看到您的网络访问量增长了很大的百分比,那么现在100个并发请求还不够)
Basically SNIReadSyncOverAsync
is so large because the web server has to sit there waiting for a response from the DB server, and the DB server can only handle 100 requests at a time so the web server ends up waiting for a long time (resulting in a 100% CPU usage and an inaccessible website). This can pop up with a recent increase in web traffic (e.g.: if you guys recently bought advertisements and saw your web traffic go up by a large percentage, now the 100 concurrent requests aren't enough)
因此,如果您像我们一样并且正在使用Azure DB,请检查DTU%的使用情况.如果其频率确实很高(80-90%等),请尝试将其提高到两倍甚至四倍(这可能很昂贵!).从弹性标准"(50 eDTU)到标准S4"(400 DTU),我们还没有看到CPU使用率达到100%.实际上,自那以来,它一直徘徊在7-9%左右.
So if you're like us and you're using Azure DB, check your DTU % usage. If its really high often (80-90%, etc.) try increasing it to double or even quadruple (this can be expensive!). We went from "Elastic Standard" (50 eDTUs) to "Standard S4" (400 DTUs) and we've yet to see the CPU usage hit 100%. In fact its been floating at around 7-9% since.
这篇关于在ASP.NET MVC4 Web应用程序上,w3wp的CPU使用率上升到100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!