성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Detecting blocking calls using asyn...
[정성태] 아쉽게도, 커뮤니티는 아니고 개인 블로그입니다. ^^
[정성태] 질문이 잘 이해가 안 됩니다. 우선, 해당 소스코드에서 ILis...
[양승조
] var대신 dinamic으로 선언해서 해결은 했습니다. 맞는 해...
[양승조
] 또 막혔습니다. ㅠㅠ var list = props[i].Ge...
[양승조
] 아. 감사합니다. 어제는 안됐던것 같은데....정신을 차려야겠네...
[정성태] "props[i].GetValue(props[i])" 코드에서 ...
[정성태] 저렇게 조각 코드 말고, 실제로 재현이 되는 예제 프로젝트를 압...
[정성태] Modules 창(Ctrl+Shift+U)을 띄워서, 해당 Op...
[정성태] 만드실 수 있습니다. 단지, Unity 엔진 내의 스크립트와 W...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>NopCommerce의 Autofac 부하(CPU, Memory)</h1> <p> 정확한 원인 분석은 아니지만, 하나의 현상이라고 기록해 둘 만한 것 같습니다.<br /> <br /> 언제부터인지는 모르겠지만 근래 NopCommerce는,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Open-source & FREE e-commerce solution: NopCommerce ; <a target='tab' href='http://www.nopcommerce.com/'>http://www.nopcommerce.com/</a> </pre> <br /> 내부적으로 DI Container로 Autofac을 사용하고 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Autofac - is an addictive Inversion of Control container for .NET Core, ASP.NET Core, .NET 4.5.1+, Universal Windows apps, and more. ; <a target='tab' href='https://autofac.org/'>https://autofac.org/</a> </pre> <br /> 그런데, 지인이 테스트하는 서버에서 CPU 사용량이 너무 높다면서 문의를 해왔습니다. 환경은, x64 .NET 4.0이었고 단지 테스트 서버이다 보니 메모리가 4GB로 낮았습니다. 2개의 테스트용 NopCommerce 사이트를 구동하면 각각 2GB 이상의 private 메모리를 차지하면서 CPU 100% 현상이 발생했습니다.<br /> <br /> 이때의 스레드 상황을 Process Explorer로 보면 다음과 같습니다.<br /> <br /> <img alt='high_mem_nopcomm_1.png' src='/SysWebRes/bbs/high_mem_nopcomm_1.png' /><br /> <br /> "clr.dll!InstallCustomModule" 항목이 눈에 띄는데요. 이런 항목이 있는 스레드 2개를 살펴보니 하나같이 "Autofac.dll"의 콜 스택이 보였습니다.<br /> <br /> <pre style='height: 400px; margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > clr.dll+0x1f30 [Managed to Unmanaged Transition] Nop.Services.dll!Nop.Services.Configuration.SettingService.LoadSetting+0x144 <span style='color: blue; font-weight: bold'>Autofac.dll!<>c__DisplayClass1`1.<ForDelegate>b__0+0x10 Autofac.dll!Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance+0x20 Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate+0x56 Autofac.dll!Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare+0x80 Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute+0xb6 Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance+0xaa Autofac.dll!Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate+0x7d Autofac.dll!Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance+0x106 Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate+0x56 Autofac.dll!Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare+0x80 Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute+0xb6 Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance+0xaa Autofac.dll!Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate+0x7d Autofac.dll!Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance+0x106 Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate+0x56 Autofac.dll!Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare+0x80 Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute+0xb6 Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance+0xaa Autofac.dll!Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate+0x7d Autofac.dll!Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance+0x106 Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate+0x56 Autofac.dll!Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare+0x80 Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute+0xb6 Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance+0xaa Autofac.dll!Autofac.Core.Resolving.ResolveOperation.Execute+0x1e Autofac.dll!Autofac.ResolutionExtensions.TryResolveService+0x7a Autofac.dll!Autofac.ResolutionExtensions.ResolveService+0x46 Autofac.dll!Autofac.ResolutionExtensions.Resolve+0x3d</span> Nop.Web.dll!Nop.Web.MvcApplication.SetWorkingCulture+0x171 System.Web.dll!SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute+0x95 System.Web.dll!System.Web.HttpApplication.ExecuteStep+0x62 System.Web.dll!PipelineStepManager.ResumeSteps+0x4fd System.Web.dll!System.Web.HttpApplication.BeginProcessRequestNotification+0x70 System.Web.dll!System.Web.HttpRuntime.ProcessRequestNotificationPrivate+0x17b System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper+0x380 System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification+0x14 [Unmanaged to Managed Transition] [Native Frame: IL Method without Metadata] clr.dll+0x21fe webengine4.dll!MgdGetCurrentNotificationInfo+0x13f webengine4.dll!RegisterModule+0x3f72 webengine4.dll!PerfIncrementGlobalCounter+0x113 webengine4.dll!MgdWebSocketWriteFragment+0x3df iiscore.dll+0xd3a9 iiscore.dll+0xcd4c iiscore.dll+0xcb96 iiscore.dll+0xdeeb iiscore.dll+0x7926 webengine4.dll!STRU::Unescape+0x501 webengine4.dll!MgdIndicateCompletion+0x22 [Native Frame: IL Method without Metadata] [Managed to Unmanaged Transition] System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper+0x45c System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification+0x14 [Unmanaged to Managed Transition] [Native Frame: IL Method without Metadata] clr.dll+0x2453 clr.dll!GetMetaDataPublicInterfaceFromInternal+0x5001a [Managed to Unmanaged Transition] [AppDomain Transition] [Unmanaged to Managed Transition] clr.dll!DllCanUnloadNowInternal+0x5004 clr.dll!GetMetaDataPublicInterfaceFromInternal+0x500c5 clr.dll+0x23fd webengine4.dll!MgdGetCurrentNotificationInfo+0x13f webengine4.dll!MgdGetCurrentNotificationInfo+0x92 clr.dll!DllCanUnloadNowInternal+0x43db clr.dll!DllCanUnloadNowInternal+0x1e9c clr.dll!DllCanUnloadNowInternal+0x1bc5 clr.dll!InstallCustomModule+0x1c7f KERNEL32.DLL!BaseThreadInitThunk+0x14 ntdll.dll!RtlUserThreadStart+0x21 </pre> <br /> <pre style='height: 400px; margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > clr.dll+0x1f30 [Managed to Unmanaged Transition] Nop.Services.dll!Nop.Services.Configuration.SettingService.LoadSetting+0x144 <span style='color: blue; font-weight: bold'>Autofac.dll!<>c__DisplayClass1`1.<ForDelegate>b__0+0x10 Autofac.dll!Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance+0x20 Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate+0x56 Autofac.dll!Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare+0x80 Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute+0xb6 Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance+0xaa Autofac.dll!Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate+0x7d Autofac.dll!Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance+0x106 Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate+0x56 Autofac.dll!Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare+0x80 Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute+0xb6 Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance+0xaa Autofac.dll!Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate+0x7d Autofac.dll!Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance+0x106 Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate+0x56 Autofac.dll!Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare+0x80 Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute+0xb6 Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance+0xaa Autofac.dll!Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate+0x7d Autofac.dll!Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance+0x106 Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate+0x56 Autofac.dll!Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare+0x80 Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute+0xb6 Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance+0xaa Autofac.dll!Autofac.Core.Resolving.ResolveOperation.Execute+0x1e Autofac.dll!Autofac.ResolutionExtensions.TryResolveService+0x7a Autofac.dll!Autofac.ResolutionExtensions.ResolveService+0x46 Autofac.dll!Autofac.ResolutionExtensions.Resolve+0x3d</span> Nop.Web.dll!Nop.Web.MvcApplication.SetWorkingCulture+0x171 System.Web.dll!SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute+0x95 System.Web.dll!System.Web.HttpApplication.ExecuteStep+0x62 System.Web.dll!PipelineStepManager.ResumeSteps+0x4fd System.Web.dll!System.Web.HttpApplication.BeginProcessRequestNotification+0x70 System.Web.dll!System.Web.HttpRuntime.ProcessRequestNotificationPrivate+0x17b System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper+0x380 System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification+0x14 [Unmanaged to Managed Transition] [Native Frame: IL Method without Metadata] clr.dll+0x21fe webengine4.dll!MgdGetCurrentNotificationInfo+0x13f webengine4.dll!RegisterModule+0x3f72 webengine4.dll!PerfIncrementGlobalCounter+0x113 webengine4.dll!MgdWebSocketWriteFragment+0x3df iiscore.dll+0xd3a9 iiscore.dll+0xcd4c iiscore.dll+0xcb96 iiscore.dll+0xdeeb iiscore.dll+0x7926 webengine4.dll!STRU::Unescape+0x501 webengine4.dll!MgdIndicateCompletion+0x22 [Native Frame: IL Method without Metadata] [Managed to Unmanaged Transition] System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper+0x45c System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification+0x14 [Unmanaged to Managed Transition] [Native Frame: IL Method without Metadata] clr.dll+0x2453 clr.dll!GetMetaDataPublicInterfaceFromInternal+0x5001a [Managed to Unmanaged Transition] [AppDomain Transition] [Unmanaged to Managed Transition] clr.dll!DllCanUnloadNowInternal+0x5004 clr.dll!GetMetaDataPublicInterfaceFromInternal+0x500c5 clr.dll+0x23fd webengine4.dll!MgdGetCurrentNotificationInfo+0x13f webengine4.dll!MgdGetCurrentNotificationInfo+0x92 clr.dll!DllCanUnloadNowInternal+0x43db clr.dll!DllCanUnloadNowInternal+0x1e9c clr.dll!DllCanUnloadNowInternal+0x1bc5 clr.dll!InstallCustomModule+0x1c7f KERNEL32.DLL!BaseThreadInitThunk+0x14 ntdll.dll!RtlUserThreadStart+0x21 </pre> <br /> 이걸 보니, Ninject DI 프레임워크의 성능 분석 사례가 떠오르더군요. ^^<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > 제니퍼 닷넷 - Ninject DI 프레임워크의 성능 분석 ; <a target='tab' href='http://www.sysnet.pe.kr/2/0/1299'>http://www.sysnet.pe.kr/2/0/1299</a> </pre> <br /> Autofac을 어떻게 적용했는지는 구체적으로 살펴보지는 않았지만, 암튼 nopCommerce 측의 적용에 문제가 있는 것이 아닌가 생각됩니다.<br /> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1564
(왼쪽의 숫자를 입력해야 합니다.)