Microsoft MVP성태의 닷넷 이야기
디버깅 기술: 84. NopCommerce의 Autofac 부하(CPU, Memory) [링크 복사], [링크+제목 복사]
조회: 16476
글쓴 사람
정성태 (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 측에 하시는 것이 더 좋지 않을까요? ^^
정성태

... [61]  62  63  64  65  66  67  68  69  70  71  72  73  74  75  ...
NoWriterDateCnt.TitleFile(s)
12092정성태12/25/201910337디버깅 기술: 148. cdb.exe를 이용해 (ntdll.dll 등에 정의된) 커널 구조체 출력하는 방법
12091정성태12/25/201911835디버깅 기술: 147. pdb 파일을 다운로드하기 위한 symchk.exe 실행에 필요한 최소 파일 [1]
12090정성태12/24/201910497.NET Framework: 871. .NET AnyCPU로 빌드된 PE 헤더의 로딩 전/후 차이점 [1]파일 다운로드1
12089정성태12/23/201911192디버깅 기술: 146. gflags와 _CrtIsMemoryBlock을 이용한 Heap 메모리 손상 여부 체크
12088정성태12/23/201910152Linux: 28. Linux - 윈도우의 "Run as different user" 기능을 shell에서 실행하는 방법
12087정성태12/21/201910633디버깅 기술: 145. windbg/sos - Dictionary의 entries 배열 내용을 모두 덤프하는 방법 (do_hashtable.py) [1]
12086정성태12/20/201912640디버깅 기술: 144. windbg - Marshal.FreeHGlobal에서 발생한 덤프 분석 사례
12085정성태12/20/201910375오류 유형: 586. iisreset - The data is invalid. (2147942413, 8007000d) 오류 발생 - 두 번째 이야기 [1]
12084정성태12/19/201911021디버깅 기술: 143. windbg/sos - Hashtable의 buckets 배열 내용을 모두 덤프하는 방법 (do_hashtable.py) [1]
12083정성태12/17/201912337Linux: 27. linux - lldb를 이용한 .NET Core 응용 프로그램의 메모리 덤프 분석 방법 [2]
12082정성태12/17/201912109오류 유형: 585. lsof: WARNING: can't stat() fuse.gvfsd-fuse file system
12081정성태12/16/201913817개발 환경 구성: 465. 로컬 PC에서 개발 중인 ASP.NET Core 웹 응용 프로그램을 다른 PC에서도 접근하는 방법 [5]
12080정성태12/16/201911824.NET Framework: 870. C# - 프로세스의 모든 핸들을 열람
12079정성태12/13/201912947오류 유형: 584. 원격 데스크톱(rdp) 환경에서 다중 또는 고용량 파일 복사 시 "Unspecified error" 오류 발생
12078정성태12/13/201912981Linux: 26. .NET Core 응용 프로그램을 위한 메모리 덤프 방법 [3]
12077정성태12/13/201912464Linux: 25. 자주 실행할 명령어 또는 초기 환경을 "~/.bashrc" 파일에 등록
12076정성태12/12/201910688디버깅 기술: 142. Linux - lldb 환경에서 sos 확장 명령어를 이용한 닷넷 프로세스 디버깅 - 배포 방법에 따른 차이
12075정성태12/11/201911546디버깅 기술: 141. Linux - lldb 환경에서 sos 확장 명령어를 이용한 닷넷 프로세스 디버깅
12074정성태12/10/201911145디버깅 기술: 140. windbg/Visual Studio - 값이 변경된 경우를 위한 정지점(BP) 설정(Data Breakpoint)
12073정성태12/10/201912993Linux: 24. Linux/C# - 실행 파일이 아닌 스크립트 형식의 명령어를 Process.Start로 실행하는 방법
12072정성태12/9/201910302오류 유형: 583. iisreset 수행 시 "No such interface supported" 오류
12071정성태12/9/201912717오류 유형: 582. 리눅스 디스크 공간 부족 및 safemode 부팅 방법
12070정성태12/9/201914805오류 유형: 581. resize2fs: Bad magic number in super-block while trying to open /dev/.../root
12069정성태12/2/201911231디버깅 기술: 139. windbg - x64 덤프 분석 시 메서드의 인자 또는 로컬 변수의 값을 확인하는 방법
12068정성태11/28/201914423디버깅 기술: 138. windbg와 Win32 API로 알아보는 Windows Heap 정보 분석 [3]파일 다운로드2
12067정성태11/27/201911239디버깅 기술: 137. 실제 사례를 통해 Debug Diagnostics 도구가 생성한 닷넷 웹 응용 프로그램의 성능 장애 보고서 설명 [1]파일 다운로드1
... [61]  62  63  64  65  66  67  68  69  70  71  72  73  74  75  ...