Microsoft MVP성태의 닷넷 이야기
디버깅 기술: 84. NopCommerce의 Autofac 부하(CPU, Memory) [링크 복사], [링크+제목 복사]
조회: 16473
글쓴 사람
정성태 (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)
12344정성태9/25/20209665Windows: 173. 서비스 관리자에 "IIS Admin Service"가 등록되어 있지 않다면?
12343정성태9/24/202019156.NET Framework: 945. C# - 닷넷 응용 프로그램에서 메모리 누수가 발생할 수 있는 패턴 [5]
12342정성태9/24/202010518디버깅 기술: 171. windbg - 인스턴스가 살아 있어 메모리 누수가 발생하고 있는지 확인하는 방법
12341정성태9/23/20209702.NET Framework: 944. C# - 인스턴스가 살아 있어 메모리 누수가 발생하고 있는지 확인하는 방법파일 다운로드1
12340정성태9/23/20209421.NET Framework: 943. WPF - WindowsFormsHost를 담은 윈도우 생성 시 메모리 누수
12339정성태9/21/20209381오류 유형: 655. 코어 모드의 윈도우는 GUI 모드의 윈도우로 교체가 안 됩니다.
12338정성태9/21/20208919오류 유형: 654. 우분투 설치 시 "CHS: Error 2001 reading sector ..." 오류 발생
12337정성태9/21/202010215오류 유형: 653. Windows - Time zone 설정을 바꿔도 반영이 안 되는 경우
12336정성태9/21/202012714.NET Framework: 942. C# - WOL(Wake On Lan) 구현
12335정성태9/21/202022130Linux: 31. 우분투 20.04 초기 설정 - 고정 IP 및 SSH 설치
12334정성태9/21/20207599오류 유형: 652. windbg - !py 확장 명령어 실행 시 "failed to find python interpreter"
12333정성태9/20/20208043.NET Framework: 941. C# - 전위/후위 증감 연산자에 대한 오버로딩 구현 (2)
12332정성태9/18/202010034.NET Framework: 940. C# - Windows Forms ListView와 DataGridView의 예제 코드파일 다운로드1
12331정성태9/18/20209222오류 유형: 651. repadmin /syncall - 0x80090322 The target principal name is incorrect.
12330정성태9/18/202010255.NET Framework: 939. C# - 전위/후위 증감 연산자에 대한 오버로딩 구현 [2]파일 다운로드1
12329정성태9/16/202012168오류 유형: 650. ASUS 메인보드 관련 소프트웨어 설치 후 ArmouryCrate.UserSessionHelper.exe 프로세스 무한 종료 현상
12328정성태9/16/202012376VS.NET IDE: 150. TFS의 이력에서 "Get This Version"과 같은 기능을 Git으로 처리한다면?
12327정성태9/12/20209977.NET Framework: 938. C# - ICS(Internet Connection Sharing) 제어파일 다운로드1
12326정성태9/12/20209527개발 환경 구성: 516. Azure VM의 Network Adapter를 실수로 비활성화한 경우
12325정성태9/12/20209077개발 환경 구성: 515. OpenVPN - 재부팅 후 ICS(Internet Connection Sharing) 기능이 동작 안하는 문제
12324정성태9/11/202010293개발 환경 구성: 514. smigdeploy.exe를 이용한 Windows Server 2016에서 2019로 마이그레이션 방법
12323정성태9/11/20209233오류 유형: 649. Copy Database Wizard - The job failed. Check the event log on the destination server for details.
12322정성태9/11/202010175개발 환경 구성: 513. Azure VM의 RDP 접속 위치 제한 [1]
12321정성태9/11/20208577오류 유형: 648. netsh http add urlacl - Error: 183 Cannot create a file when that file already exists.
12320정성태9/11/20209705개발 환경 구성: 512. RDP(원격 데스크톱) 접속 시 비밀 번호를 한 번 더 입력해야 하는 경우
12319정성태9/10/20209461오류 유형: 647. smigdeploy.exe를 Windows Server 2016에서 실행할 때 .NET Framework 미설치 오류 발생
... 46  47  48  49  50  [51]  52  53  54  55  56  57  58  59  60  ...