Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 3개 있습니다.)

.NET Core 2.2/3.0 웹 프로젝트를 IIS에서 호스팅(Inproc, out-of-proc)하는 방법 - AspNetCoreModuleV2 소개

지난 글에서 이미 한번 방법을 설명했는데요.

ASP.NET Core (EXE) 프로세스가 IIS에서 호스팅되는 방법 - ASP.NET Core Module(AspNetCoreModule)
; https://www.sysnet.pe.kr/2/0/11436

어느새 2.2가 나오고는 AspNetCoreModule도 새 버전으로 AspNetCoreModuleV2가 추가되었습니다.

ASP.NET Core In Process Hosting on IIS with ASP.NET Core 2.2
; https://weblog.west-wind.com/posts/2019/Mar/16/ASPNET-Core-Hosting-on-IIS-with-ASPNET-Core-22

Current .NET Core Hosting Bundle installer (direct download)
; https://www.microsoft.com/net/permalink/dotnetcore-current-windows-runtime-bundle-installer

AspNetCoreModuleV2가 내세우는 특장점이라면, 바로 "InProcess" 활성화를 지원한다는 것입니다. 예전에는 w3wp.exe가 단순한 Reverse Proxy로만 동작하고 Kestral 웹 서버에 호스팅 중인 ASP.NET Core 프로세스에서 웹 응용 프로그램이 구동되는 방식이어서 별도의 TCP 소켓 통신이 발생하는 오버헤드가 있었는데요. AspNetCoreModuleV2는 w3wp.exe 프로세스 내부에 ASP.NET Core 웹 응용 프로그램을 직접 로드할 수 있는 모드를 추가함으로써 성능을 더욱 향상시켰다는데 의미가 있습니다.

실제로 간단하게 구성해 볼까요? ^^ 우선, ".NET Core 3" 프로젝트를 생성 후 web.config 파일을 추가하고 AspNetCoreModuleV2 모듈 및 그것이 사용할 설정을 추가합니다.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!-- To customize the asp.net core module uncomment and edit the following section. 
  For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
  <system.webServer>
    <handlers>
      <remove name="aspNetCore" />
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false"
            stdoutLogFile=".\logs\stdout" hostingModel="InProcess">
      <environmentVariables>
        <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
      </environmentVariables>
    </aspNetCore>
  </system.webServer>
</configuration>

이제 "dotnet publish" 명령어로 배포를 하게 되면,

dotnet.exe publish /p:Configuration=Release  -r win-x64

".\bin\Release\netcoreapp3.0\win-x64\publish" 하위 폴더에 다음과 같이 web.config이 바뀐 것을 볼 수 있습니다.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!-- To customize the asp.net core module uncomment and edit the following section. 
  For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
  <system.webServer>
    <handlers>
      <remove name="aspNetCore" />
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath=".\Core3Web.exe" arguments="" stdoutLogEnabled="false"
             stdoutLogFile=".\logs\stdout" hostingModel="InProcess">
      <environmentVariables>
        <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
      </environmentVariables>
    </aspNetCore>
  </system.webServer>
</configuration>
<!--ProjectGuid: AD6EE067-E62F-4C8F-9590-CBC9CC3A1E50-->

여기까지 했으면 응용 프로그램으로써 할 일은 모두 끝입니다. 남은 작업은 ".\bin\Release\netcoreapp3.0\win-x64\publish" 폴더를 IIS 웹 서버에 복사해 주면 되는데, 이때 해당 웹 서버에는 .NET Core가 설치될 필요는 없지만 "ASP.NET Core/.NET Core: Runtime & Hosting Bundle"은 설치해야 합니다.

Download .NET Core 3.0
; https://dotnet.microsoft.com/download/dotnet-core/3.0

ASP.NET Core/.NET Core: Runtime & Hosting Bundle
; https://dotnet.microsoft.com/download/thank-you/dotnet-runtime-3.0.0-windows-hosting-bundle-installer

끝입니다. 이후 IIS 웹 사이트 설정만 해당 폴더로 연결되어 있으면 웹 브라우저를 통해 ASP.NET Core 웹 응용 프로그램이 w3wp.exe 단독으로 호스팅하는 것을 볼 수 있습니다. (이로 인해 V1 모듈(AspNetCoreModule)에서는 ASPNETCORE_PORT와 같은 환경 변수가 필요했지만 V2에서는 더 이상 사용하지 않게 됩니다.)




물론 이전처럼 분리된 프로세스로 실행하는 것도 가능합니다. 이를 위해 web.config의 hostingModel 옵션만 OutOfProcess로 바꾸면 됩니다.

<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false"
    stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess">

좀 더 자세한 사항은 아래의 공식 문서에서 확인할 수 있습니다.

ASP.NET Core Module
; https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module




참고로 OutOfProcess로 호스팅되는 경우, w3wp.exe에는 다음과 같은 식의 lm 결과를 통해,

start             end                 module name
000001f3`852c0000 000001f3`852fb000   iisres     (no symbols)           
00007ff7`b1280000 00007ff7`b128b000   w3wp       (pdb symbols)          e:\symbols\w3wp.pdb\167FBC957A3EC18C5796F4C3C7E1AF6F1\w3wp.pdb
00007ff8`8a650000 00007ff8`8a6a4000   aspnetcorev2   (deferred)             
00007ff8`8a6b0000 00007ff8`8a703000   iiscore    (deferred)             
00007ff8`8aa20000 00007ff8`8aa64000   aspnetcore   (deferred)             
00007ff8`8ac30000 00007ff8`8acd8000   webengine4   (deferred)             
00007ff8`8ade0000 00007ff8`8ae14000   webdav     (deferred)             
00007ff8`8b120000 00007ff8`8b146000   isapi      (deferred)             
00007ff8`8c200000 00007ff8`8c212000   iiswsock   (deferred)             
00007ff8`8d970000 00007ff8`8d985000   wshbth     (deferred)             
00007ff8`90470000 00007ff8`9047c000   aspnet_filter   (deferred)             
00007ff8`90520000 00007ff8`9053c000   iisfcgi    (deferred)             
00007ff8`90700000 00007ff8`9072e000   iisfreb    (deferred)             
00007ff8`90840000 00007ff8`90856000   filter     (deferred)             
00007ff8`90860000 00007ff8`90885000   iisetw     (deferred)             
00007ff8`90e20000 00007ff8`90e32000   winrnr     (deferred)             
00007ff8`90e40000 00007ff8`90e5b000   pnrpnsp    (deferred)             
00007ff8`90e60000 00007ff8`90e77000   NapiNSP    (deferred)             
00007ff8`90ea0000 00007ff8`90ead000   warmup     (deferred)             
00007ff8`90f30000 00007ff8`90f3a000   validcfg   (deferred)             
00007ff8`90f70000 00007ff8`90f80000   cgi        (deferred)             
00007ff8`910e0000 00007ff8`910eb000   iisreqs    (deferred)             
00007ff8`910f0000 00007ff8`91101000   custerr    (deferred)             
00007ff8`91110000 00007ff8`9111b000   logcust    (deferred)             
00007ff8`91fa0000 00007ff8`91fb0000   modrqflt   (deferred)             
00007ff8`91fb0000 00007ff8`91fc0000   authanon   (deferred)             
00007ff8`91fc0000 00007ff8`91fcf000   static     (deferred)             
00007ff8`920c0000 00007ff8`920ce000   iis_ssi    (deferred)             
00007ff8`920d0000 00007ff8`920da000   redirect   (deferred)             
00007ff8`92eb0000 00007ff8`92ebb000   protsup    (deferred)             
00007ff8`99ee0000 00007ff8`99eeb000   dirlist    (deferred)             
00007ff8`9a320000 00007ff8`9a332000   cachhttp   (deferred)             
00007ff8`9a360000 00007ff8`9a380000   w3dt       (deferred)             
00007ff8`9a5b0000 00007ff8`9a5ba000   defdoc     (deferred)             
00007ff8`a0e60000 00007ff8`a0ea2000   mlang      (deferred)             
00007ff8`a1230000 00007ff8`a12c8000   webio      (deferred)             
00007ff8`a2400000 00007ff8`a240f000   httpapi    (deferred)             
00007ff8`a26d0000 00007ff8`a278d000   ucrtbase_clr0400   (deferred)             
00007ff8`a2b50000 00007ff8`a2b5b000   ktmw32     (deferred)             
00007ff8`a2b90000 00007ff8`a2ba6000   VCRUNTIME140_CLR0400   (deferred)             
00007ff8`a2d30000 00007ff8`a2d3c000   secur32    (deferred)             
00007ff8`a2d90000 00007ff8`a2e0d000   nativerd   (deferred)             
00007ff8`a2e80000 00007ff8`a2ece000   iisutil    (deferred)             
00007ff8`a2f40000 00007ff8`a2f49000   cachtokn   (deferred)             
00007ff8`a3a40000 00007ff8`a4575000   clr        (deferred)             
00007ff8`abd20000 00007ff8`abd2b000   cachfile   (deferred)             
00007ff8`ae2b0000 00007ff8`ae35a000   mscoreei   (deferred)             
00007ff8`ae8a0000 00007ff8`ae905000   mscoree    (deferred)             
00007ff8`aeda0000 00007ff8`aedaa000   rasadhlp   (deferred)             
00007ff8`aedd0000 00007ff8`aee50000   FWPUCLNT   (deferred)             
00007ff8`aee50000 00007ff8`aef5a000   winhttp    (deferred)             
00007ff8`b2dd0000 00007ff8`b2dda000   version    (deferred)             
00007ff8`b3260000 00007ff8`b326b000   winnsi     (deferred)             
00007ff8`b3b10000 00007ff8`b3b20000   websocket   (deferred)             
00007ff8`b4340000 00007ff8`b4376000   xmllite    (deferred)             
00007ff8`b44c0000 00007ff8`b44dd000   nlaapi     (deferred)             
00007ff8`b46b0000 00007ff8`b46c8000   w3wphost   (pdb symbols)          e:\symbols\w3wphost.pdb\18462E890C1A7E73A1A70DA1953EF7DE1\w3wphost.pdb
00007ff8`b48f0000 00007ff8`b48f9000   cachuri    (deferred)             
00007ff8`b6390000 00007ff8`b639f000   loghttp    (deferred)             
00007ff8`b63a0000 00007ff8`b63ac000   w3tp       (deferred)             
00007ff8`b6b10000 00007ff8`b6b22000   kernel_appcore   (deferred)             
00007ff8`b78f0000 00007ff8`b7923000   ntmarta    (deferred)             
00007ff8`b7cc0000 00007ff8`b7cf4000   rsaenh     (deferred)             
00007ff8`b8050000 00007ff8`b808b000   IPHLPAPI   (deferred)             
00007ff8`b8090000 00007ff8`b815b000   dnsapi     (deferred)             
00007ff8`b83b0000 00007ff8`b841a000   mswsock    (deferred)             
00007ff8`b85a0000 00007ff8`b85b8000   cryptsp    (deferred)             
00007ff8`b85c0000 00007ff8`b85cc000   CRYPTBASE   (deferred)             
00007ff8`b8680000 00007ff8`b86bb000   ntasn1     (deferred)             
00007ff8`b86c0000 00007ff8`b86e7000   ncrypt     (deferred)             
00007ff8`b89f0000 00007ff8`b89fa000   dpapi      (deferred)             
00007ff8`b8ab0000 00007ff8`b8ae2000   sspicli    (deferred)             
00007ff8`b8af0000 00007ff8`b8b1e000   userenv    (deferred)             
00007ff8`b8bf0000 00007ff8`b8c17000   bcrypt     (deferred)             
00007ff8`b8c20000 00007ff8`b8d76000   crypt32    (deferred)             
00007ff8`b8d80000 00007ff8`b8e8b000   gdi32full   (deferred)             
00007ff8`b8e90000 00007ff8`b8f12000   bcryptPrimitives   (deferred)             
00007ff8`b8f20000 00007ff8`b8fbd000   msvcp_win   (deferred)             
00007ff8`b9130000 00007ff8`b9230000   ucrtbase   (deferred)             
00007ff8`b9230000 00007ff8`b94fe000   KERNELBASE   (pdb symbols)          e:\symbols\kernelbase.pdb\464250F2BF052A1D1D9DCE321151C5711\kernelbase.pdb
00007ff8`b9500000 00007ff8`b9522000   win32u     (deferred)             
00007ff8`b9530000 00007ff8`b9538000   psapi      (deferred)             
00007ff8`b9540000 00007ff8`b956a000   gdi32      (deferred)             
00007ff8`b97d0000 00007ff8`b988d000   kernel32   (pdb symbols)          e:\symbols\kernel32.pdb\9CF2BCBC4D0E03503C68E569FAA6DC931\kernel32.pdb
00007ff8`b9b50000 00007ff8`b9bfe000   advapi32   (deferred)             
00007ff8`b9c00000 00007ff8`b9ca9000   clbcatq    (deferred)             
00007ff8`b9ce0000 00007ff8`b9d7e000   msvcrt     (deferred)             
00007ff8`b9d80000 00007ff8`b9ea5000   rpcrt4     (deferred)             
00007ff8`b9eb0000 00007ff8`b9eb8000   nsi        (deferred)             
00007ff8`b9ec0000 00007ff8`b9f6d000   SHCore     (deferred)             
00007ff8`b9f70000 00007ff8`b9fc5000   shlwapi    (deferred)             
00007ff8`b9fd0000 00007ff8`ba170000   user32     (deferred)             
00007ff8`ba1a0000 00007ff8`ba26d000   oleaut32   (deferred)             
00007ff8`ba270000 00007ff8`ba5c4000   combase    (deferred)             
00007ff8`ba630000 00007ff8`ba75a000   ole32      (deferred)             
00007ff8`ba760000 00007ff8`ba7fc000   sechost    (deferred)             
00007ff8`bacd0000 00007ff8`bb414000   shell32    (deferred)             
00007ff8`bb420000 00007ff8`bb48b000   ws2_32     (deferred)             
00007ff8`bb4d0000 00007ff8`bb6c8000   ntdll      (pdb symbols)          e:\symbols\ntdll.pdb\CDE75D039306834203EBD8D4E7D503691\ntdll.pdb

aspnetcorev2가 중계만 하는 것을 알 수 있습니다. 또한 이것을 대상으로 sos 확장 명령어를 실행하면 다음과 같은 결과들만 볼 수 있습니다.

0:000> .loadby sos clr

0:000> !name2ee *!ANY
Failed to request module list.


0:000> !dumpheap
Error requesting GC Heap data
Unable to build snapshot of the garbage collector state

0:000> !threads
Failed to request ThreadStore




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

[연관 글]






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

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

비밀번호

댓글 작성자
 




... 61  62  63  64  65  66  [67]  68  69  70  71  72  73  74  75  ...
NoWriterDateCnt.TitleFile(s)
11965정성태6/30/201911853.NET Framework: 846. C# - 2차원 배열을 1차원 배열로 나열하는 확장 메서드파일 다운로드1
11964정성태6/30/201913288Linux: 20. C# - Linux에서의 Named Pipe를 이용한 통신
11963정성태6/29/201913021Linux: 19. C# - .NET Core Unix Domain Socket 사용 예제
11962정성태6/27/201910712Math: 61. C# - 로지스틱 회귀를 이용한 선형분리 불가능 문제의 분류파일 다운로드1
11961정성태6/27/201910237Graphics: 37. C# - PLplot - 출력 모음(Family File Output)
11960정성태6/27/201911052Graphics: 36. C# - PLplot의 16색 이상을 표현하는 방법과 subpage를 이용한 그리드 맵 표현
11959정성태6/27/201912210Graphics: 35. matplotlib와 PLplot의 한글 처리
11958정성태6/25/201916533Linux: 18. C# - .NET Core Console로 리눅스 daemon 프로그램 만드는 방법 [6]
11957정성태6/24/201915605Windows: 160. WMI 쿼리를 명령행에서 간단하게 수행하는 wmic.exe [2]
11956정성태6/24/201913639Linux: 17. CentOS 7에서 .NET Core Web App 실행 환경 구성 [1]
11955정성태6/20/201911944Math: 60. C# - 로지스틱 회귀를 이용한 분류파일 다운로드1
11954정성태6/20/201911344오류 유형: 550. scp - sudo: no tty present and no askpass program specified
11953정성태6/20/201910184오류 유형: 549. The library 'libhostpolicy.so' required to execute the application was not found in '...'
11952정성태6/20/201910958Linux: 16. 우분투, Centos의 Netbios 호스트 이름 풀이 방법
11951정성태6/20/201913783오류 유형: 548. scp 연결 시 "Permission denied" 오류 및 "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!" 경고
11950정성태6/18/201912576.NET Framework: 845. C# - 윈도우 작업 관리자와 리소스 모니터의 메모리 값을 구하는 방법
11949정성태6/18/20199008오류 유형: 547. CoreCLR Profiler 예제 프로젝트 빌드 시 컴파일 오류 유형
11948정성태6/17/201911286Linux: 15. 리눅스 환경의 Visual Studio Code에서 TFS 서버 연동
11947정성태6/17/201912581Linux: 14. 리눅스 환경에서 TFS 서버 연동
11946정성태6/17/201913181개발 환경 구성: 445. C# - MathNet으로 정규 분포를 따르는 데이터를 생성, PLplot으로 Histogram 표현파일 다운로드1
11945정성태6/17/201911572Linux: 13. node.js에서 syslog로 출력하는 방법
11944정성태6/16/201918343Linux: 12. Ubuntu 16.04/18.04에서 node.js 최신 버전 설치 방법
11943정성태6/15/201911154.NET Framework: 844. C# - 박싱과 언박싱 [1]
11942정성태6/13/201917581개발 환경 구성: 444. 로컬의 Visual Studio Code로 원격 리눅스 머신에 접속해 개발하는 방법 [1]
11941정성태6/13/201910906오류 유형: 546. "message NETSDK1057: You are using a preview version of .NET Core" 빌드 경고 없애는 방법
11940정성태6/13/201910836개발 환경 구성: 443. Visual Studio의 Connection Manager 기능(Remote SSH 관리)을 위한 명령행 도구파일 다운로드1
... 61  62  63  64  65  66  [67]  68  69  70  71  72  73  74  75  ...