Microsoft MVP성태의 닷넷 이야기
디버깅 기술: 84. NopCommerce의 Autofac 부하(CPU, Memory) [링크 복사], [링크+제목 복사]
조회: 16415
글쓴 사람
정성태 (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)
12443정성태12/8/20208969.NET Framework: 977. C# PInvoke - C++의 매개변수에 대한 마샬링을 tlbexp.exe를 이용해 확인하는 방법
12442정성태12/4/20207958오류 유형: 691. Visual Studio - Build Events에 robocopy를 사용할때 "Invalid Parameter #1" 오류가 발행하는 경우
12441정성태12/4/20207626오류 유형: 690. robocopy - ERROR : No Destination Directory Specified.
12440정성태12/4/20208661오류 유형: 689. SignTool Error: Invalid option: /as
12439정성태12/4/20209878디버깅 기술: 176. windbg - 특정 Win32 API에서 BP가 안 걸리는 경우 (2) [1]
12438정성태12/2/20209861오류 유형: 688. .Visual C++ - Error C2011 'sockaddr': 'struct' type redefinition
12437정성태12/1/20209424VS.NET IDE: 155. pfx의 암호 키 파일을 Visual Studio 없이 등록하는 방법
12436정성태12/1/20209745오류 유형: 687. .NET Core 2.2 빌드 - error MSB4018: The "RazorTagHelper" task failed unexpectedly.
12435정성태12/1/202015190Windows: 181. 윈도우 환경에서 클라이언트 소켓의 최대 접속 수 (4) - ReuseUnicastPort를 이용한 포트 고갈 문제 해결 [1]파일 다운로드1
12434정성태11/30/202010499Windows: 180. C# - dynamicport 값의 범위를 알아내는 방법
12433정성태11/29/20209572Windows: 179. 윈도우 환경에서 클라이언트 소켓의 최대 접속 수 (3) - SO_PORT_SCALABILITY파일 다운로드1
12432정성태11/29/202011034Windows: 178. 윈도우 환경에서 클라이언트 소켓의 최대 접속 수 (2) - SO_REUSEADDR [1]파일 다운로드1
12431정성태11/27/20208959.NET Framework: 976. UnmanagedCallersOnly + C# 9.0 함수 포인터 사용 시 x86 빌드에서 오동작하는 문제파일 다운로드1
12430정성태11/27/20209657오류 유형: 686. Ubuntu - E: The repository 'cdrom://...' does not have a Release file.
12429정성태11/25/20209729디버깅 기술: 175. windbg - 특정 Win32 API에서 BP가 안 걸리는 경우
12428정성태11/25/20208700VS.NET IDE: 154. Visual Studio - .NET Core App 실행 시 dotnet.exe 실행 화면만 나오는 문제
12427정성태11/24/20209818.NET Framework: 975. .NET Core를 직접 호스팅해 (runtimeconfig.json 없이) EXE만 배포해 실행파일 다운로드1
12426정성태11/24/20208478오류 유형: 685. WinDbg Preview - error InitTypeRead
12425정성태11/24/20209487VC++: 141. Visual C++ - "Treat Warnings As Errors" 옵션이 꺼져 있는데도 일부 경고가 에러 처리되는 경우
12424정성태11/24/20209920VC++: 140. C++의 연산자 동의어(operator synonyms), 대체 토큰 [1]
12423정성태11/22/202010833.NET Framework: 974. C# 9.0 - (16) 제약 조건이 없는 형식 매개변수 주석(Unconstrained type parameter annotations)파일 다운로드1
12422정성태11/21/20208652.NET Framework: 973. .NET 5, .NET Framework에서만 허용하는 UnmanagedCallersOnly 사용예파일 다운로드1
12421정성태11/19/20208413.NET Framework: 972. DNNE가 출력한 NE DLL을 직접 생성하는 방법파일 다운로드1
12420정성태11/19/20207612오류 유형: 684. Visual C++ - MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
12419정성태11/19/20208776VC++: 139. Visual C++ - .NET Core의 nethost.lib와 정적 링크파일 다운로드1
12418정성태11/19/202010850오류 유형: 683. Visual C++ - error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug'파일 다운로드1
... 46  [47]  48  49  50  51  52  53  54  55  56  57  58  59  60  ...