CPU usage of w3wp rises to 100% on a ASP.NET MVC4 web application

耗尽温柔 提交于 2019-12-12 10:57:33

问题


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.

Server: Windows 2008 R2 Standard SP1 IIS: 7 (V 7.5.7600.16385) Only one application pool and one webapplication is running.

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 

Have you an idea what is the reason of this CPU rising?


回答1:


Hey I had the exact same issue with SNIReadSyncOverAsync using a significant amount of thread time (I discovered this using DebugDiag).

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.

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)

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.



来源:https://stackoverflow.com/questions/14609129/cpu-usage-of-w3wp-rises-to-100-on-a-asp-net-mvc4-web-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!