[Windows] IIS Worker Process(w3wp.exe)์—์„œ ๋ฉ”๋ชจ๋ฆฌ ๋ˆ„์ˆ˜(Memory Leak) ํ˜„์ƒ ๋ฐœ์ƒ (+IIS Application Pool Recycle)

2022. 7. 8. 23:34ใ†TIL/Windows

โ˜„๏ธ ๋ฌธ์ œ

๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋ฅ (%)

๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ์ง€์†์ ์œผ๋กœ ์ฆ๊ฐ€ํ•˜๊ณ  ํŠธ๋ž˜ํ”ฝ์ด ๋งŽ์€ ๊ฒฝ์šฐ ์ฆ๊ฐ€ ์†๋„๊ฐ€ ๋นจ๋ผ์ง„๋‹ค.

๐ŸŒŽ ํ™˜๊ฒฝ

  • AWS EC2
    • OS: Windows 2019
    • Software : Internet Information Services (IIS)

 


 

๐Ÿ”ซ Trouble Shooting

1. ํ”„๋กœ์„ธ์Šค ํ™•์ธ

์„œ๋ฒ„ ์ ‘์† ํ›„ ์ž‘์—… ๊ด€๋ฆฌ์ž๋กœ ํ™•์ธํ•œ ๊ฒฐ๊ณผ, ๋‹จ ํ•˜๋‚˜์˜ w3wp.exe๊ฐ€ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ๊ณผ๋„ํ•˜๊ฒŒ ์‚ฌ์šฉ ์ค‘์ด์—ˆ์œผ๋ฉฐ ํ•ด๋‹น ํ”„๋กœ์„ธ์Šค์˜ ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋Ÿ‰์ด ๊ณ„์† ์ฆ๊ฐ€ ์ค‘.

์ž‘์—… ๊ด€๋ฆฌ์ž

2. Application Pool ํ™•์ธ

pID๋ฅผ ์ด์šฉํ•˜์—ฌ ํ•ด๋‹น ํ”„๋กœ์„ธ์Šค๊ฐ€ ์–ด๋–ค IIS Worker Process์ธ์ง€ ํŒŒ์›Œ์‰˜์—์„œ ์•„๋ž˜์˜ ๋ช…๋ น์–ด๋กœ ํ™•์ธํ•œ๋‹ค.

1์—์„œ ํ™•์ธํ•œ PID(41920)์— ๋Œ€ํ•œ Application Pool์˜ ์ •์ฒด๋ฅผ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

C:\\Windows\\System32\\inetsrv\\appcmd.exe list wp

๋˜๋Š” IIS Manager ์ฝ˜์†” > Worker Processes ํŽ˜์ด์ง€์—์„œ๋„ ํ™•์ธ ๊ฐ€๋Šฅ.

3. IIS Application Pool Recycle (์•ฑํ’€ ์žฌ์ƒ)

๋‹น์žฅ์˜ ํ•ด๊ฒฐ์„ ์œ„ํ•ด ์ž„์‹œ๋ฐฉํŽธ์œผ๋กœ 2๋ฒˆ์—์„œ ํ™•์ธํ•œ Application Pool์— ๋Œ€ํ•ด Recycle์„ ์ง„ํ–‰ํ•˜์—ฌ ๋ฉ”๋ชจ๋ฆฌ ๋ฐ˜ํ™˜.

IIS Manager > Application Pools > Application ์šฐํด๋ฆญ > Recycle

Application Pool Recycle์„ ์ˆ˜ํ–‰ํ•˜๋ฉด ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋ฅ ์ด ์•„๋ž˜์™€ ๊ฐ™์ด ๋ชจ๋‹ˆํ„ฐ๋ง๋œ๋‹ค.

๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋Ÿ‰์ด ๊ฑฐ์˜ ์ˆ˜์ง์œผ๋กœ ๊ฐ์†Œํ•˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

IIS Application Pool Recycle ํ›„, ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋ฅ (%)

4. ๋ฌธ์ œ ํ•ด๊ฒฐ

IIS Application Pool Recycle ํ›„, ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋ฅ (%)

3๋ฒˆ์—์„œ IIS Application Pool Recycle์œผ๋กœ ๋ฉ”๋ชจ๋ฆฌ ๋ฐ˜ํ™˜ ํ›„์—๋„ ์œ„ ์บก์ฒ˜๋ณธ๊ณผ ๊ฐ™์ด ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋ฅ ์€ ์ฆ๊ฐ€ํ•˜์˜€๋‹ค.

๋”๋ถˆ์–ด, ํ•œ ํ”„๋กœ์„ธ์Šค์˜ ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋Ÿ‰์ด ์œ„์™€ ๊ฐ™์ด ์šฐ์ƒํ–ฅ์œผ๋กœ ์ฆ๊ฐ€ํ•˜๋Š” ๊ฒƒ๊ณผ ์ธ์ž…๋˜๋Š” ํŠธ๋ž˜ํ”ฝ์ด ๋งŽ์„ ๋•Œ ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋Ÿ‰์ด ๊ธ‰์ฆํ•˜๋Š” ๊ฒƒ์œผ๋กœ ๋ณด์•„ ๋ฉ”๋ชจ๋ฆฌ ๋ˆ„์ˆ˜(Memory Leak) ํ˜„์ƒ์œผ๋กœ ํŒ๋‹จํ•˜์˜€๋‹ค.

์ด์— ๋”ฐ๋ผ ๊ฐœ๋ฐœ์ž๊ฐ€ ์˜์‹ฌ๋˜๋Š” ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•˜์˜€๊ณ  ์ดํ›„ ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋ฅ ์€ ์ •์ƒ์ ์ธ ์–‘์ƒ์œผ๋กœ ๋ชจ๋‹ˆํ„ฐ๋ง๋˜๊ณ  ์žˆ๋‹ค.

ํ•ด๊ฒฐ ์™„๋ฃŒ~!

 

 


 

๐Ÿ’ก IIS Application Pool (Worker Process)๋ž€?

  • IIS Application Pool : IIS ๋‚ด์—์„œ ์‹คํ–‰๋˜๋Š” ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ.
  • IIS Worker Process(w3wp.exe)๋Š” IIS Application Pool์— ๋Œ€ํ•ด IIS ์›น ์„œ๋ฒ„๋กœ ์ „์†ก๋œ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•œ๋‹ค.
  • IIS Application Pool์ด ์‹œ์ž‘๋˜์—ˆ๋‹ค๊ณ  ํ•ด์„œ IIS worker process(w3wp)๊ฐ€ ์‹คํ–‰๋˜๊ณ  ์žˆ์ง€ ์•Š์„ ์ˆ˜ ์žˆ๋‹ค. IIS๋Š” ์›น ์š”์ฒญ์„ ๋ฐ›์„ ๋•Œ๊นŒ์ง€ worker process๋ฅผ ์‹œ์ž‘ํ•˜์ง€ ์•Š๋Š”๋‹ค.
    • ๋”ฐ๋ผ์„œ, IIS Manager ์ฝ˜์†”์—์„œ Application Pools์—์„œ ๋ณด์ด๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋ชฉ๋ก๊ณผ Worker Processes ํŽ˜์ด์ง€์—์„œ ๋ณด์ด๋Š” ํ”„๋กœ์„ธ์Šค ๋ชฉ๋ก์ด ๊ฐ™์ง€ ์•Š์„ ์ˆ˜ ์žˆ๋‹ค.
  • โ™ป๏ธ Application Pool Recycle์ด๋ž€?
    • ์ƒˆ๋กœ์šด worker process๋ฅผ ๋จผ์ € ์ƒ์„ฑํ•˜๊ณ , ๊ธฐ์กด ํ”„๋กœ์„ธ์Šค๋ฅผ ์ •์ƒ ์ข…๋ฃŒํ•˜๋Š” ๊ณผ์ •.
    • recycle(์žฌ์ƒ) ์‹œ, ๋“ค์–ด์˜ค๋Š” ์š”์ฒญ๋“ค์€ ์‹ ๊ทœ worker process๊ฐ€ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ด๋‹น ํ”„๋กœ์„ธ์Šค์˜ ๋Œ€๊ธฐ์—ด์— ์š”์ฒญ์„ ๋„ฃ๋Š”๋‹ค. ๊ธฐ์กด ์ž‘์—…์ž ํ”„๋กœ์„ธ์Šค๋Š” ์ด๋ฏธ ๋ฐ›์•„์„œ ์ฒ˜๋ฆฌํ•˜๊ณ  ์žˆ๋˜ ์š”์ฒญ์„ ๋๋‚ด๊ณ , ์ข…๋ฃŒํ•œ๋‹ค.
    • ๋”ฐ๋ผ์„œ ์žฌ์ƒ์„ ์ˆ˜ํ–‰ํ•˜๋”๋ผ๋„ ๋ชจ๋“  ์š”์ฒญ์— ๋Œ€ํ•ด ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋‹ค. ๋ชจ๋“  ์š”์ฒญ์— ๋Œ€ํ•ด ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋‹ค.
    • Trouble Shooting์˜ 3๋ฒˆ๊ณผ ๊ฐ™์ด ํšจ๊ณผ์ ์œผ๋กœ ์‹œ์Šคํ…œ ๋ฆฌ์†Œ์Šค(๋ฉ”๋ชจ๋ฆฌ)๋ฅผ ๋ฐ˜ํ™˜ํ•  ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ ๋ฉ”๋ชจ๋ฆฌ ๋ˆ„์ˆ˜ ํ˜„์ƒ์— ๋Œ€ํ•ด์„œ ๊ทผ๋ณธ์ ์ธ ํ•ด๊ฒฐ์ฑ…์€ ์•„๋‹ˆ๋‹ค.
    • ์ฐธ๊ณ ๋กœ, Application๋ณ„๋กœ Recycle ์ฃผ๊ธฐ๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด์™ธ Recycle์— ๋Œ€ํ•œ ์—ฌ๋Ÿฌ ์˜ต์…˜์„ ์ค„ ์ˆ˜ ์žˆ๋‹ค.

IIS Manager > Application Pools > Application ์šฐํด๋ฆญ > Advanced Settings
Application Pools > Application Advanced Settings > Recycling

 

๐Ÿ”— ์ฐธ๊ณ  ๋งํฌ

  1. ๊ธฐ์ˆ  ๋ธ”๋กœ๊ทธ : What is w3wp.exe? Learn the Basics About IIS Worker Processes
  2. ๊ธฐ์ˆ  ๋ธ”๋กœ๊ทธ : IISRESET VS ์‘์šฉํ”„๋กœ๊ทธ๋žจ ํ’€ ์žฌํ™œ์šฉ(Recycle)