Microsoft MVP성태의 닷넷 이야기
디버깅 기술: 84. NopCommerce의 Autofac 부하(CPU, Memory) [링크 복사], [링크+제목 복사]
조회: 16475
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

NopCommerce의 Autofac 부하(CPU, Memory)

정확한 원인 분석은 아니지만, 하나의 현상이라고 기록해 둘 만한 것 같습니다.

언제부터인지는 모르겠지만 근래 NopCommerce는,

Open-source & FREE e-commerce solution: NopCommerce
; http://www.nopcommerce.com/

내부적으로 DI Container로 Autofac을 사용하고 있습니다.

Autofac - is an addictive Inversion of Control container for .NET Core, ASP.NET Core, .NET 4.5.1+, Universal Windows apps, and more.
; https://autofac.org/

그런데, 지인이 테스트하는 서버에서 CPU 사용량이 너무 높다면서 문의를 해왔습니다. 환경은, x64 .NET 4.0이었고 단지 테스트 서버이다 보니 메모리가 4GB로 낮았습니다. 2개의 테스트용 NopCommerce 사이트를 구동하면 각각 2GB 이상의 private 메모리를 차지하면서 CPU 100% 현상이 발생했습니다.

이때의 스레드 상황을 Process Explorer로 보면 다음과 같습니다.

high_mem_nopcomm_1.png

"clr.dll!InstallCustomModule" 항목이 눈에 띄는데요. 이런 항목이 있는 스레드 2개를 살펴보니 하나같이 "Autofac.dll"의 콜 스택이 보였습니다.

clr.dll+0x1f30
[Managed to Unmanaged Transition]
Nop.Services.dll!Nop.Services.Configuration.SettingService.LoadSetting+0x144
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
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

clr.dll+0x1f30
[Managed to Unmanaged Transition]
Nop.Services.dll!Nop.Services.Configuration.SettingService.LoadSetting+0x144
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
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

이걸 보니, Ninject DI 프레임워크의 성능 분석 사례가 떠오르더군요. ^^

제니퍼 닷넷 - Ninject DI 프레임워크의 성능 분석
; https://www.sysnet.pe.kr/2/0/1299

Autofac을 어떻게 적용했는지는 구체적으로 살펴보지는 않았지만, 암튼 nopCommerce 측의 적용에 문제가 있는 것이 아닌가 생각됩니다.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 7/10/2021]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 



2016-12-28 02시38분
[ryujh] 안녕하세요.

내용 중에 '내부적으로 DI Container로 Autofac을 사용하고 있습니다' 이렇다면 NopCommerce 에 포함되었다는 것인데
NopCommerce 에서 Autofac 을 분리 가능한지 문의합니다. 소스 수정이 필요하다면 DI Container 를 사용하기 위해 소스 수정 작업이 더해지는 결과인데 DI 의 이점이 충분히 큰지요?

DI 사용해본 적없고 소스 수정 작업만 걱정하다보니 이런 질문하는군요. 감사합니다.
[guest]
2016-12-30 01시31분
글쎄요. 그 질문은 NopCommerce 측에 하시는 것이 더 좋지 않을까요? ^^
정성태

... 46  47  48  49  50  51  52  53  54  [55]  56  57  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
12242정성태6/23/20209037오류 유형: 623. AADSTS90072 - User account '...' from identity provider 'live.com' does not exist in tenant 'Microsoft Services'
12241정성태6/23/202012296.NET Framework: 914. C# - Task.Yield 사용법파일 다운로드1
12240정성태6/23/202013592오류 유형: 622. 소켓 바인딩 시 "System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions" 오류 발생
12239정성태6/21/202010023Linux: 30. (윈도우라면 DLL에 속하는) .so 파일이 텍스트로 구성된 사례 [1]
12238정성태6/21/20209996.NET Framework: 913. C# - SharpDX + DXGI를 이용한 윈도우 화면 캡처 라이브러리
12237정성태6/20/20209768.NET Framework: 912. 리눅스 환경의 .NET Core에서 "test".IndexOf("\0")가 0을 반환
12236정성태6/19/202010156오류 유형: 621. .NET Standard 대상으로 빌드 시 dynamic 예약어에서 컴파일 오류 - error CS0656: Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'
12235정성태6/19/20209812오류 유형: 620. Windows 10 - Inaccessible boot device 블루 스크린
12234정성태6/19/20209504개발 환경 구성: 494. NuGet - nuspec의 패키지 스키마 버전(네임스페이스) 업데이트 방법
12233정성태6/19/20209194오류 유형: 619. SQL 서버 - The transaction log for database '...' is full due to 'LOG_BACKUP'. - 두 번째 이야기
12232정성태6/19/20208170오류 유형: 618. SharePoint - StoreBusyRetryLater 오류
12231정성태6/15/202010561.NET Framework: 911. Console/Service Application을 위한 SynchronizationContext - AsyncContext
12230정성태6/15/20209964오류 유형: 617. IMetaDataImport::GetMethodProps가 반환하는 IL 코드 주소(RVA) 문제
12229정성태6/13/202011814.NET Framework: 910. USB/IP PROJECT를 이용해 C#으로 USB Keyboard + Mouse 가상 장치 만들기 [1]
12228정성태6/12/202011887.NET Framework: 909. C# - Source Generator를 적용한 XmlCodeGenerator파일 다운로드1
12227정성태6/12/202015829오류 유형: 616. Visual Studio의 느린 업데이트 속도에 대한 원인 분석 [5]
12226정성태6/11/202013175개발 환경 구성: 493. OpenVPN의 네트워크 구성 [4]파일 다운로드1
12225정성태6/11/202012116개발 환경 구성: 492. 윈도우에 OpenVPN 설치 - 클라이언트 측 구성
12224정성태6/11/202019950개발 환경 구성: 491. 윈도우에 OpenVPN 설치 - 서버 측 구성 [1]
12223정성태6/9/202014006.NET Framework: 908. C# - Source Generator 소개 [10]파일 다운로드2
12222정성태6/3/20209910VS.NET IDE: 146. error information: "CryptQueryObject" (-2147024893/0x80070003)
12221정성태6/3/20209728Windows: 170. 비어 있지 않은 디렉터리로 symbolic link(junction) 연결하는 방법
12220정성태6/3/202012076.NET Framework: 907. C# DLL로부터 TLB 및 C/C++ 헤더 파일(TLH)을 생성하는 방법
12219정성태6/1/202011222.NET Framework: 906. C# - lock (this), lock (typeof(...))를 사용하면 안 되는 이유파일 다운로드1
12218정성태5/27/202011188.NET Framework: 905. C# - DirectX 게임 클라이언트 실행 중 키보드 입력을 감지하는 방법 [3]
12217정성태5/24/20209681오류 유형: 615. Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1.
... 46  47  48  49  50  51  52  53  54  [55]  56  57  58  59  60  ...