ã¯ããã«
Windows Server 2008 R2 / IIS 7.5以éãå®è¡ããŠããéçšWebãµãŒããŒãèªåã§ã»ããã¢ããããå¿ èŠããããŸãããïŒ IISã®äœ¿çšçµéšãè±å¯ãªã·ã¹ãã 管çè ã«ãšã£ãŠãããã¯ãã¶ãç°¡åãªäœæ¥ã§ãããããŸããŸãªçç±ã§ãæŠéããµãŒããŒã®ã»ããã¢ããã«åå ããªããã°ãªããªãWebéçºè ã«ãšã£ãŠããã®æ å ±ã¯éåžžã«åœ¹ç«ã¡ãŸãã
ããã§ã¯ãå§ããŸãããã ASP.NETã§ã®ãµã€ãã®é«éå-äŒæ¥ã®ãéãšç®¡çè ã®ç¥çµãç¯çŽããŸãã
èæ¯
1. IISæ§æãªãã·ã§ã³
2. ASP.NETãæ§æãã
3.åºæ¬æ§æãæé©åããããã®æšå¥šäºé
ãªãã·ã§ãã«
ãããã«
åç §è³æ
èæ¯
æšå¹Žæ«ããã倧èŠæš¡ãªçµç¹ã§ããŠãŒã¶ãŒã®è² è·ãæ¥æ¿ã«å¢å ãããšããWebãµãŒããŒã®ããã©ãŒãã³ã¹ã®åé¡ã«çŽé¢ããŸããã åœæã200,000人以äžã®é¡§å®¢ãWebã¢ããªã±ãŒã·ã§ã³ã«ç»é²ãããŠããŸããã éåžžã¢ãŒãã§ã¯ãçŽ1000人ã®ãŠãŒã¶ãŒãåæã«äœæ¥ããŸããããã¯ã1æ¥ãããã®ç»é²ãŠãŒã¶ãŒã®ç·æ°ã®ãŠããŒã¯ããžã¿ãŒã®çŽ10ã15ïŒ ã§ãããããè² è·ã¯æ¯èŒçäœããªããŸãã ãã ããã·ã¹ãã ãå®éã«åäœäžèœã«ãªãããŒã¯è² è·ããããŸãã
Web管çè ã¯å¯èœãªãã¹ãŠããã§ãã¯ããŸããããäœãåé¡ãªã®ãç解ã§ããŸããã§ããã å®éãç©çã¬ãã«ã§ã®ã·ã¹ãã ã®ãã¹ãŠã®äž»èŠãªãã©ã¡ãŒã¿ãŒã«ã€ããŠã¯ããã©ãŒãã³ã¹ãè¯å¥œã§ãããšããäºå®ã«ããããããããµãŒãã¹ã®å¯çšæ§ã«é害ãããããªã¯ãšã¹ãã®èšå€§ãªãã¥ãŒãããŒã«ã«åéãããŸããã çµç¹ã¯4ã€ã®ããŒãïŒWindows Server 2008 R2 + IIS 7.5 + .NET 4.5ïŒã«NLBã¯ã©ã¹ã¿ãŒã䜿çšããŸããCPUãšã¡ã¢ãªãèªã¿èŸŒãããã®äºåãããããããã¯ãŒã¯ãã£ãã«ã倧ããã䜿çšããããŒãã®æ°ã¯ååã§ãã ãã¹ãŠã®ãã§ãã¯ã¯ãåé¡ãIISã®è žãšASP.NETããŒã«ã®æ§æã«ããããšã瀺ããŸããã 管çè ãçµéšè±å¯ãªWebéçºè ã®å©ããå·ã€ããªããããªçããäŸ...
1. IISæ§æãªãã·ã§ã³
.NETæ§æã®æŠèŠ
IIS 7以éããã¹ãŠã®ASP.NETæ§æèšå®ã¯XMLãã¡ã€ã«ïŒ* .configïŒã«ä¿åãããŸãã IIS 6.0以åã§äœ¿çšãããŠããã¡ã¿ããŒã¹ã眮ãæããŸããã
IIS 7.x以éã®æ§æãã¡ã€ã«å³ã¯æ¬¡ã®ããã«ãªããŸãã
å³ 1.èšå®ãã¡ã€ã«ã®ã¹ããŒã
éå±€.NETæ§æã®æäžéšã«ããã®ã¯machine.configãã¡ã€ã«ã§ã ã ç¹å®ã®ãã·ã³ã®ã°ããŒãã«ãã©ã¡ãŒã¿ãå®çŸ©ããŸãã ãã®ãã¡ã€ã«ã¯ãæ§æãã¡ã€ã«ã®ãµããŒããããŠããã»ã¯ã·ã§ã³ãå®çŸ©ããASP.NETã¯ãŒã¯ãããŒãæ§æããããŸããŸãªã¢ãžã¥ãŒã«ãããã€ããŒãç»é²ããŸãã åæåããã»ã¹ãæé©åããããã«ã machine.configãã¡ã€ã«ã¯å€§å¹ ã«ç°¡çŽ åããã次ã®ãã£ã¬ã¯ããªã«é 眮ãããŠããŸãã
machine.config.commentsãã¡ã€ã«ã¯æ¬¡ã®ãšããã§ããããã«ãããããã©ã«ãã§äœ¿çšãããŠãããã©ã¡ãŒã¿ãŒã確èªã§ããŸãã ãã®ããŒã¿ã䜿çšããŠããªãŒããŒã©ã€ããããå€ãæã€ãã©ã¡ãŒã¿ãŒãmachine.configã«è¿œå ã§ããŸãã
ASP.NETæ§æéå±€ã®ã«ãŒãã¯ã machine.configãšåããã£ã¬ã¯ããªã«ããweb.configãã¡ã€ã«ã§ã ã ãã®ãã¡ã€ã«ã«ã¯ããã¹ãŠã®ASP.NETã¢ããªã±ãŒã·ã§ã³ã«äœ¿çšããããã©ã¡ãŒã¿ãŒãå«ãŸããŠããŸãã
ApplicationHost.config-ã«ãŒãIISæ§æãã¡ã€ã«ã«ã¯ããã¹ãŠã®ãµã€ããã¢ããªã±ãŒã·ã§ã³ãä»®æ³ãã£ã¬ã¯ããªãã¢ããªã±ãŒã·ã§ã³ããŒã«ã®èª¬æãããã³WebãµãŒããŒèšå®ã®ã°ããŒãã«ãªããã©ã«ãèšå®ãå«ãŸããŸãã OSããŒãžã§ã³ã«å¿ããŠã次ã®ãã©ã«ããŒã«ãããŸãã
åããŒã«ã«web.configãã¡ã€ã«ã¯ãããã眮ãããŠãããã£ã¬ã¯ããªãšãã¹ãŠã®åãã£ã¬ã¯ããªã®æ§æèšå®ãé©çšããŸãã ãµããã£ã¬ã¯ããªã®èšå®ã¯ãç¬èªã®ãconfigsãã§äžæžãã§ããŸãã
IIS 7.x以éã®æ§æãã¡ã€ã«å³ã¯æ¬¡ã®ããã«ãªããŸãã
å³ 1.èšå®ãã¡ã€ã«ã®ã¹ããŒã
éå±€.NETæ§æã®æäžéšã«ããã®ã¯machine.configãã¡ã€ã«ã§ã ã ç¹å®ã®ãã·ã³ã®ã°ããŒãã«ãã©ã¡ãŒã¿ãå®çŸ©ããŸãã ãã®ãã¡ã€ã«ã¯ãæ§æãã¡ã€ã«ã®ãµããŒããããŠããã»ã¯ã·ã§ã³ãå®çŸ©ããASP.NETã¯ãŒã¯ãããŒãæ§æããããŸããŸãªã¢ãžã¥ãŒã«ãããã€ããŒãç»é²ããŸãã åæåããã»ã¹ãæé©åããããã«ã machine.configãã¡ã€ã«ã¯å€§å¹ ã«ç°¡çŽ åããã次ã®ãã£ã¬ã¯ããªã«é 眮ãããŠããŸãã
%systemroot%\Microsoft.NET\Framework\<versionNumber>\CONFIG\
machine.config.commentsãã¡ã€ã«ã¯æ¬¡ã®ãšããã§ããããã«ãããããã©ã«ãã§äœ¿çšãããŠãããã©ã¡ãŒã¿ãŒã確èªã§ããŸãã ãã®ããŒã¿ã䜿çšããŠããªãŒããŒã©ã€ããããå€ãæã€ãã©ã¡ãŒã¿ãŒãmachine.configã«è¿œå ã§ããŸãã
ASP.NETæ§æéå±€ã®ã«ãŒãã¯ã machine.configãšåããã£ã¬ã¯ããªã«ããweb.configãã¡ã€ã«ã§ã ã ãã®ãã¡ã€ã«ã«ã¯ããã¹ãŠã®ASP.NETã¢ããªã±ãŒã·ã§ã³ã«äœ¿çšããããã©ã¡ãŒã¿ãŒãå«ãŸããŠããŸãã
ApplicationHost.config-ã«ãŒãIISæ§æãã¡ã€ã«ã«ã¯ããã¹ãŠã®ãµã€ããã¢ããªã±ãŒã·ã§ã³ãä»®æ³ãã£ã¬ã¯ããªãã¢ããªã±ãŒã·ã§ã³ããŒã«ã®èª¬æãããã³WebãµãŒããŒèšå®ã®ã°ããŒãã«ãªããã©ã«ãèšå®ãå«ãŸããŸãã OSããŒãžã§ã³ã«å¿ããŠã次ã®ãã©ã«ããŒã«ãããŸãã
- 32ãããã®å Žå-ïŒ WINDIRïŒ \ System32 \ inetsrv \ config \
- 64ãããã®å Žå-ïŒ WINDIRïŒ \ SysWOW64 \ inetsrv \ config \
åããŒã«ã«web.configãã¡ã€ã«ã¯ãããã眮ãããŠãããã£ã¬ã¯ããªãšãã¹ãŠã®åãã£ã¬ã¯ããªã®æ§æèšå®ãé©çšããŸãã ãµããã£ã¬ã¯ããªã®èšå®ã¯ãç¬èªã®ãconfigsãã§äžæžãã§ããŸãã
IISã®æ§æãéå§ããåã«ãASP.NETããã©ãŒãã³ã¹ã«ãŠã³ã¿ãŒã«æ³šæãæããçŸåšããã³æ倧ã®ã·ã¹ãã è² è·ãè©äŸ¡ããå©çšå¯èœãªã€ã³ãžã±ãŒã¿ãŒãä¿®æ£ããŸãã ãHTTPãšã©ãŒ503.2-ãµãŒãã¹ãå©çšã§ããŸããããšãããšã©ãŒã®ãã°ã確èªããŸãã ãªã¯ãšã¹ãã®äžéšããã¥ãŒã§ãããã¯ãããŠãããã©ããã確èªããŠãã ããã
ã·ã¹ãã ã®ããã©ãŒãã³ã¹ã顧客ã®ããŒãºãæºãããŠããå Žåãã»ãšãã©ã®ASP.NETã¢ããªã±ãŒã·ã§ã³çšã«èšèšãããŠãããããããã©ã«ãèšå®ã®ãŸãŸã«ããŠããããšããå§ãããŸãã
IISãæ§æããå Žåãã¢ããªã±ãŒã·ã§ã³ã®å¯çšæ§ãšãã®ããã©ãŒãã³ã¹ã«åœ±é¿ãã2ã€ã®äž»èŠãªãã©ã¡ãŒã¿ãŒããããŸãã
1.ãã©ã¡ãŒã¿ãŒappConcurrentRequestLimitã¯ãã¢ããªã±ãŒã·ã§ã³å ã®åæãªã¯ãšã¹ãã®æ倧æ°ã§ãã åæãªã¯ãšã¹ãã®æ°ãå¢ãããšãIISã¯ãªã¯ãšã¹ããåŠçããããã«å©çšå¯èœãªWebãµãŒããŒãªãœãŒã¹ãæ¡åŒµããŸãã ããã©ã«ãå€ã¯5000ã§ãã
appConcurrentRequestLimitãã©ã¡ãŒã¿ãŒãå€æŽããæãç°¡åãªæ¹æ³ã¯ãã³ãã³ãã©ã€ã³ããappcmd.exeãŠãŒãã£ãªãã£ã䜿çšããããšã§ãã ããã¯ã ApplicationHost.configãã¡ã€ã«ã䜿çšããŠãã¹ãŠã®IISãµã€ãã«å¯ŸããŠã°ããŒãã«ã«å®è¡ããããšããåäžã®ãµã€ãïŒã¢ããªã±ãŒã·ã§ã³ïŒã«å¯ŸããŠå®è¡ããããšãã§ããŸãã
cd %windir%\system32\inetsrv appcmd.exe set config /section:system.webserver/serverRuntime /appConcurrentRequestLimit:20000
ã³ãã³ããå®è¡ããIISã®ã«ãŒããã£ã¬ã¯ããªã®ãæ§æãšãã£ã¿ãŒãã»ã¯ã·ã§ã³ãéããset appConcurrentRequestLimitãã©ã¡ãŒã¿ãŒã®æ°ããå€ã確èªããŸãã ããã§ããã®å€ãæåã§å€æŽã§ããŸãã
å³ 2. appConcurrentRequestLimitã®èšå®
ãã®ãã©ã¡ãŒã¿ãŒãèšå®ããããã«ãæãäžè¬çã«äœ¿çšãããåŒã¯æ¬¡ã®ãšããã§ãã
< usersCount * 1.5 >ã usersCountã¯åæãŠãŒã¶ãŒã®æ°ã§ãã
2. QueueLengthãã©ã¡ãŒã¿ãŒã¯ãHttp.sysãã©ã€ããŒãã¢ããªã±ãŒã·ã§ã³ããŒã«ãã¥ãŒã«å ¥ããèŠæ±ã®æ倧æ°ã§ãã ãã¥ãŒããã£ã±ãã«ãªããšãæ°ãããªã¯ãšã¹ãã«ã503.2-Service Unavailableããšãããšã©ãŒã衚瀺ãããŸãã ããã©ã«ãå€ã¯5000ã§ãã
ãã®ãã©ã¡ãŒã¿ãŒã¯ãããã€ãã®æ¹æ³ã§æ§æã§ããŸãã
- machine.configã»ã¯ã·ã§ã³processModel / requestQueueLimitãä»ãããµãŒããŒã¬ãã«ã§ã®.NETã®ã°ããŒãã«
- ApplicationHost.configãä»ããŠIISã¬ãã«ã§ïŒsystem.web / httpRuntime-> appRequestQueueLimit;
- ç¹å®ã®ããŒã«ã®queueLengthãã©ã¡ãŒã¿ãŒã®å€ãèšå®ããŸãã
äŸãšããŠãã³ãã³ãã©ã€ã³ã䜿çšããŠãDefaultAppPoolãããŒã«ã®ãã®ãã©ã¡ãŒã¿ãŒãå€æŽããŸãã
appcmd.exe set apppool "DefaultAppPool" /queueLength:20000
ã³ãã³ããå®è¡ããIISã§[ã¢ããªã±ãŒã·ã§ã³ããŒã«]ã»ã¯ã·ã§ã³ãéãããªã¹ãã§[DefaultAppPool]ããŒã«ãéžæãã[詳现èšå®]ã¡ãã¥ãŒã«ç§»åããŠç¢ºèªããŸãã
å³ 3. queueLengthãã©ã¡ãŒã¿ãŒã®èšå®
泚ïŒãIIS-> Worker Processesããä»ããŠå®è¡äžã®ããŒã«ã®çŸåšã®ãªã¯ãšã¹ãã衚瀺ãã
IISãããŒãžã£ãŒã§ãããªãŒå
ã®ãµãŒããŒããŒããéžæãã[ã¯ãŒã«ãŒããã»ã¹]ã¢ã€ã³ã³ãã¯ãªãã¯ããŸãã
å³ 4. IISãããŒãžã£ãŒã®ã¯ãŒã«ãŒããã»ã¹ã¡ãã¥ãŒ
衚瀺ããããªã¹ãã§ãçŸåšå®è¡äžã®ãã¹ãŠã®ããŒã«ã®ããŠã³ããŒãã確èªã§ããŸãã
å³ 5.ã¯ãŒã«ãŒããã»ã¹ãä»ããŠäœæ¥ããŒã«ã衚瀺ãã
[çŸåšã®ãªã¯ãšã¹ãã衚瀺]ãã¯ãªãã¯ãããšãåŠçãããããŒãžã¢ãã¬ã¹ãšãã®ä»ã®äŸ¿å©ãªãã©ã¡ãŒã¿ãŒã®ãªã¹ããå«ãããŒãã«ã衚瀺ãããŸãã ãªã¹ããæŽæ°ããã«ã¯ãç»é¢ã§F5ãæŒããŸãã ãããã£ãŠãããã³ã°ãã¯ãšãªãèŠã€ããããšãã§ããŸãã
å³ 6.ããŒã«å ã®çŸåšã®ãªã¯ãšã¹ãã®ãªã¹ã
ãã¡ãããããã©ãŒãã³ã¹ã€ã³ãžã±ãŒã¿ãŒã衚瀺ããã«ã¯ãããã©ãŒãã³ã¹ã¢ãã¿ãŒã«ãŠã³ã¿ãŒã䜿çšããããšããå§ãããŸããããªã¯ãšã¹ãã¢ãã¿ãŒã®ããã«ãçŸåšã®ãªã¯ãšã¹ãã®URLã¯è¡šç€ºãããŸããã
å³ 4. IISãããŒãžã£ãŒã®ã¯ãŒã«ãŒããã»ã¹ã¡ãã¥ãŒ
衚瀺ããããªã¹ãã§ãçŸåšå®è¡äžã®ãã¹ãŠã®ããŒã«ã®ããŠã³ããŒãã確èªã§ããŸãã
å³ 5.ã¯ãŒã«ãŒããã»ã¹ãä»ããŠäœæ¥ããŒã«ã衚瀺ãã
[çŸåšã®ãªã¯ãšã¹ãã衚瀺]ãã¯ãªãã¯ãããšãåŠçãããããŒãžã¢ãã¬ã¹ãšãã®ä»ã®äŸ¿å©ãªãã©ã¡ãŒã¿ãŒã®ãªã¹ããå«ãããŒãã«ã衚瀺ãããŸãã ãªã¹ããæŽæ°ããã«ã¯ãç»é¢ã§F5ãæŒããŸãã ãããã£ãŠãããã³ã°ãã¯ãšãªãèŠã€ããããšãã§ããŸãã
å³ 6.ããŒã«å ã®çŸåšã®ãªã¯ãšã¹ãã®ãªã¹ã
ãã¡ãããããã©ãŒãã³ã¹ã€ã³ãžã±ãŒã¿ãŒã衚瀺ããã«ã¯ãããã©ãŒãã³ã¹ã¢ãã¿ãŒã«ãŠã³ã¿ãŒã䜿çšããããšããå§ãããŸããããªã¯ãšã¹ãã¢ãã¿ãŒã®ããã«ãçŸåšã®ãªã¯ãšã¹ãã®URLã¯è¡šç€ºãããŸããã
2. ASP.NETãæ§æãã
ASP.NETã¯ããªã¯ãšã¹ãã®å®è¡ã«äœ¿çšãããã¯ãŒã«ãŒã¹ã¬ãããšåŒã³åºãçµäºããŒãã¹ã¬ããã®æ°ãå¶éããŸãã ãµãŒããŒåŽã®Webã¢ããªã±ãŒã·ã§ã³ããSystem.NETåå空éã®æšæºã¯ã©ã¹ã§ããå€éšWebãµãŒãã¹åŒã³åºããåºç¯å²ã«äœ¿çšããŠãããã¯ãŒã¯çµç±ã§èŠæ±ãæŽçãããšãããã©ãŒãã³ã¹ã®äœäžãšãããããã¯ã®ç«¶åãçºçããå¯èœæ§ããããŸãã æåã¯ããªã¯ãšã¹ãã®äžéšãåçŽã«ããã³ã°ãããããšããããå®è¡æéãå€§å¹ ã«å¢å ããŸãã ææªã®å Žåãã¯ã©ã·ãã¯ããŒã«æ§æã¢ãŒãïŒã¯ã©ã·ãã¯ãã€ãã©ã€ã³ïŒã䜿çšãããšãäžè¬çã«ããŒã«ã®åèµ·åïŒãªãµã€ã¯ã«ïŒã«ã€ãªããå¯èœæ§ããããŸãã çµ±åã¢ãŒãã§å®è¡ãããŠããããŒã«ã®ASP.NETãããããã¯æ€åºã¯å€±æããŸã ïŒIIS 7以éã®ããã©ã«ãïŒã
çµ±åã¢ãŒãã§ã¢ããªã±ãŒã·ã§ã³ããŒã«ã䜿çšãããšãã¯ã©ã·ãã¯ã¢ãŒãã§ã®äœæ¥ãããããã€ãã®å©ç¹ããããŸãã çµ±åã¢ãŒãã§ã¢ããªã±ãŒã·ã§ã³ããŒã«ãå®è¡ããããšããå§ãããŸãã
次ã®å³ã¯ãASP.NETã§ã®èŠæ±ã®åŠçæ¹æ³ãšæãéèŠãªãã©ã¡ãŒã¿ãŒãæ確ã«ç€ºããŠããŸãã
å³ 7. ASP.NETã®ãªã¯ãšã¹ãåŠçããã»ã¹
Webã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ãæé©åããããã«ãããŒã«èšå®ã®èªåæ§æã®ããã©ã«ãã¢ãŒããæå¹ã«ãªã£ãŠããŸãã ãã®å Žåã machine.configãã¡ã€ã«ã® < processModel >ã»ã¯ã·ã§ã³ã®autoConfig ããããã£ã¯ã true ãã§ãããä»ã®äž»èŠãªãã©ã¡ãŒã¿ãŒã¯ãŸã£ããèšå®ãããŠããŸããã
MSDNãšmachine.config.commentsãã¡ã€ã«ã培åºçã«ã調ã¹ããŠãããŒã«ã®åºæ¬æ§æã®èª¬æãèŠã€ããŸããã ASP.NETããµãŒãã¹ããã³ãããã¯ãŒã¯ãšé£æºããæ¹æ³ã«åœ±é¿ãã7ã€ã®äž»èŠãªãã©ã¡ãŒã¿ãŒããããŸãã
- maxConnection
- maxWorkerThreads / minWorkerThreads
- maxIoThreads / minIoThreads
- minFreeThreads
- minLocalRequestFreeThreads
maxconnectionãã©ã¡ãŒã¿ãŒã¯ã1ã€ã®IPã¢ãã¬ã¹ããã®åæèŠæ±ã®æ倧æ°ã決å®ããŸãã ããŒã«ã®èªåæ§æãããã©ã«ãã§æå¹ã«ãªã£ãŠããå Žåããã®ãã©ã¡ãŒã¿ãŒã¯åŒã«ãã£ãŠæ±ºå®ãããŸãã
maxConnection = 12 * cpuNum ãããã§cpuNumã¯ããã»ããµã³ã¢ã®æ°
ãããã£ãŠã4ã³ã¢ããã»ããµãæèŒãããµãŒããŒã§ã¯ãæçµIPã¢ãã¬ã¹ãžã®åææ¥ç¶ã®æ倧æ°ã¯48 = 12 * 4ïŒããã©ã«ãïŒã§ãã
ãã®å¶éãåé¿ããæãç°¡åãªæ¹æ³ã¯ãASP.NETã¢ããªã±ãŒã·ã§ã³ã®ã³ãŒãã§global.asaxãã¡ã€ã«ã®Application_Startã¡ãœããã§æ¬¡ãçŽæ¥æå®ããããšã§ãã
// maximum number of concurrent connections allowed by a ServicePoint object System.Net.ServicePointManager.DefaultConnectionLimit = Int16.MaxValue;
ã¢ããªã±ãŒã·ã§ã³ãã¡ã€ã³ã¬ãã«ïŒweb.configïŒãŸãã¯WebãµãŒããŒïŒapplicationHost.configïŒã®æ§æãã¡ã€ã«ã䜿çšããŠã maxconnectionãããæè»ã«æ§æããããšããå§ãããŸãã < system.net >ã»ã¯ã·ã§ã³ã«ã¯ã.NET Frameworkããããã¯ãŒã¯ã«æ¥ç¶ããæ¹æ³ã決å®ãããã©ã¡ãŒã¿ãŒãå«ãŸããŠããŸãã
<system.net> <connectionManagement> <add address="*" maxconnection="5000" /> <add address = "http://www.habrahabr.ru" maxconnection = "9999" /> <add address = "http://65.53.32.230:88" maxconnection = "240" /> </connectionManagement> </system.net>
éèŠïŒ maxconnectionãã©ã¡ãŒã¿ã¢ãã¬ã¹ã®ã¬ã€ã¢ãŠãã¯æ¬¡ã®ããã«ãªããŸãã
http(s)://<IP- >:<>
maxconnectionãå¢ãããšããªã¢ãŒããµãŒãã¹ã«å¯ŸããŠããå€ãã®åæåŒã³åºããè¡ãããšãã§ããŸãã ãã®å±æ§ã¯ãããŒã«ã«WebãµãŒãã¹ã®åŒã³åºãã«ã¯åœ±é¿ããŸããïŒ ãµãŒãã¹ãžã®åææ¥ç¶æ°ã®å¶éããã€ãã¹ããã ãã§ã¯äžååã§ããããšãç解ããå¿ èŠããããŸãã åæåŒã³åºãã®æ°ãå¢å ãããšããªã¢ãŒãã®äœæãšã³ãŒã«ããã¯ã®åŠçã«äœ¿çšãããCLRãããŒã®äœ¿çšãå¢å ããããã§ãã
ASP.NETã¯ã maxWorkerThreadsãã©ã¡ãŒã¿ãŒã䜿çšããŠã w3wp.exeã¯ãŒã¯ãã㌠ïŒIIS 7以éïŒã®ã¹ã¬ããå¶éãèšå®ããŸãã ASP.NETã¯IISã«çµã¿èŸŒãŸããŠãããããASP.NETããã»ã¹ã¯ã¯ãŒã«ãŒã¹ã¬ããã§ãªã¯ãšã¹ããçæããŸãã CLR ThreadPoolã®ã¹ã¬ããæ°ãäžååãªãããèŠæ±ã¯ãã¥ãŒã«å ¥ããããŠãã³ã°ããŸãã
< processModel >ã»ã¯ã·ã§ã³ã§æå®ãããå±æ§ïŒ
1.ãã©ã¡ãŒã¿ãŒmaxWorkerThreads -CLRç°å¢ã®ã¹ã¬ããããŒã«å ã®åããã»ããµãŒã®ã¯ãŒã«ãŒã¹ã¬ããã®æ倧æ°ã瀺ããŸãã ããã©ã«ãå€ã¯20ã§ããæ倧å€ã¯100ã§ãã
2. maxIoThreadsãã©ã¡ãŒã¿ãŒ-CLRã¹ã¬ããããŒã«å ã®åããã»ããµãŒã®å ¥å/åºåã¹ã¬ããã®æ倧æ°ã瀺ããŸãã ããã©ã«ãå€ã¯20ã§ããæ倧å€ã¯100ã§ãã
3.ãã©ã¡ãŒã¿minWorkerThreads-ãªã¢ãŒããªã¯ãšã¹ããåŠçããããã«ããã«æäŸã§ããåããã»ããµã®ã¯ãŒã¯ã¹ã¬ããã®æå°æ°ã瀺ããŸãã ããã©ã«ãå€ã¯1ã§ãã
4. minIoThreadsãã©ã¡ãŒã¿ãŒ-ã³ãŒã«ããã¯åŠçã«ããã«æäŸã§ããåããã»ããµãŒã®å ¥å/åºåã¹ã¬ããã®æå°æ°ã瀺ããŸãã ããã©ã«ãå€ã¯1ã§ãã
ãã©ã¡ãŒã¿minWorkerThreads / minIoThreadsã䜿çšãããšã éã¢ã¯ãã£ãã®å Žåã«ã¹ã¬ããããŒã«ãæé©ãªã¹ã¬ããã¬ãã«ã«å°éããã®ã«ååãªæéããªãå Žåã«ãçªç¶å¢å ããåææ¥ç¶æ°ã«ãã°ãã察åŠã§ããŸãã
< httpRuntime >ã»ã¯ã·ã§ã³ã§å®çŸ©ãããŠããå±æ§ïŒ
1.ãã©ã¡ãŒã¿minFreeThreads-ã¯ãŒã¯ãããŒãžã®çä¿¡èŠæ±ã®åŠçã«å ããŠãäœæ¥ã«äœ¿çšã§ããã¹ã¬ããã®æ°ã決å®ããŸãã ãã®ãã©ã¡ãŒã¿ãŒã¯ãããŒã«å ã®ã¹ã¬ããã®åèšæ°ããã®å¶éãäžåã£ãå Žåã«ãASP.NETããã»ã¹ãããŒã«ã®ã¹ã¬ããã䜿çšããŠæ°ããHTTPèŠæ±ãåŠçããã®ãé²ããŸãã ããã©ã«ãå€ã¯8ã§ãã
2.ãã©ã¡ãŒã¿minLocalRequestFreeThreads-ASP.NETãæ°ããããŒã«ã«ãªã¯ãšã¹ãã«äœ¿çšã§ãã空ãã¹ã¬ããã®æå°æ°ã決å®ããŸãã ããã©ã«ãå€ã¯4ã§ãã
ãã©ã¡ãŒã¿ãŒmaxWorkerThreads ã minWorkerThreads ã maxIoThreads ã minIoThreadsã«ã¯æé»çã«ããã»ããµãŒã®æ°ãæãããããã©ã¡ãŒã¿ãŒminFreeThreadsããã³minLocalRequestFreeThreadsã¯æããããªãããšã«æ³šæããŠãã ããã
ASP.NETã¯ã次ã®åæãªã¯ãšã¹ãæ°ãè¶ ããŠå®è¡ããŸããã
ïŒ maxWorkerThreads * CPUçªå· ïŒ -minFreeThreads
泚ïŒã¢ããªã±ãŒã·ã§ã³ããŒã«å šäœãã€ãŸããããŒã«ãæäŸããåw3wp.exeã¯ãŒã«ãŒããã»ã¹ã«å¯ŸããŠã1ã€ã®CLR ThreadPoolã¹ã¬ããããŒã«ããããŸãã 1ã€ã®ããŒã«ã§æ§æããããã¹ãŠã®ã¢ããªã±ãŒã·ã§ã³ãã¡ã€ã³ïŒãµã€ãïŒã«å¯ŸããŠãå ±éã®ã¹ã¬ããã»ããã䜿çšãããŸãã ãããã£ãŠããªãœãŒã¹ãå¿ èŠãšããã¢ããªã±ãŒã·ã§ã³ã®å Žåã¯ãåå¥ã®ããŒã«ã䜿çšããããšããå§ãããŸãã
3.åºæ¬æ§æãæé©åããããã®æšå¥šäºé
ãŸããWebãµãŒããŒäžã®ããã»ããµã®æ°ãæ£ç¢ºã«å€æããå¿ èŠããããŸãã ãŸãã¯ãTaskManager->ã¿ããPerformanceããèŠãããšãã§ããŸãã ããã»ããµãHyperThreadingTechnology ïŒHTTïŒã¢ãŒãããµããŒãããŠããå Žåãã³ã¢ã®ååã¯ç©çïŒã³ã¢ïŒã§ã¯ãªãè«çïŒè«çããã»ããµïŒã§ãã ããšãã°ãHTTã¢ãŒããæå¹ã«ãªã£ãŠããå Žåã4ã€ã®ç©çã³ã¢ãæã€ããã»ããµãŒã¯8ã€ã®è«çã³ã¢ãšããŠæ©èœããŸãã
å³ 8. TaskManagerã®ããã»ããµããŒããŠã£ã³ããŠ
ã³ãã³ãã©ã€ã³ã§æ¬¡ã®ã³ãã³ãã䜿çšããŠè©Šãããšãã§ããŸãã
ãŸãã¯WMIC CPU Get DeviceID,NumberOfCores,NumberOfLogicalProcessors
echo %NUMBER_OF_PROCESSORS%
ããšãã°ã4ã€ã®ããã»ããµãšautoConfig = " true "ããããã£ãæã€ãµãŒããŒã§ã¯ãASP.NETã«ã¯æ¬¡ã®ããã©ã«ãèšå®ããããŸãã
maxConnection-48; maxWorkerThreads-80; maxIoThreads-80ãminFreeThreads-8ãminLocalRequestFreeThreads-4ã
ããã¯ãšã³ãéšåã®WebããŒãžãåãªã¯ãšã¹ãã«å¯ŸããŠè€æ°ã®ãããã¯ãŒã¯åŒã³åºããè¡ãå ŽåãMSDNã¯æ¬¡ã®æ§æèšå®ã䜿çšããããšããå§ãããŸãã
- maxWorkerThreads = 100 | minWorkerThreads = maxWorkerThreads / 2 = 50
- maxIoThreads = 100
- maxConnection = 12 * N
- minFreeThreads = 88 * N
- minLocalRequestFreeThreads = 76 * Nãããã§Nã¯ããã»ããµã®æ°ã§ãã
ãã®ã»ã¯ã·ã§ã³ã§ã¯ãã¬ã€ãã©ã€ã³ã®ã¿ãæäŸããã«ãŒã«ã¯æäŸããŸããã ããã«ããã®ããŒã¿ã®å ¬éæ¥ã¯ããªãå€ãã§ãã ãæŠéãã·ã¹ãã ã§ã¯ããããã«ç°ãªãæ§æãã©ã¡ãŒã¿ãŒã䜿çšããŸãã ãããã®åŒã¯ãæé©åãéå§ããããã®è¯ãåºçºç¹ã§ããããã©ã¡ãŒã¿ãŒã®çžäºäŸåæ§ããã瀺ããŠããŸãã ããšãã°ã maxConnectionãã©ã¡ãŒã¿ãŒã®å€ãæ°åå¢ãããšãæ®ãã®ãã©ã¡ãŒã¿ãŒã®åºæ¬å€ãç°¡åã«ãæšå®ãã§ããŸãã
< processModel >ã»ã¯ã·ã§ã³ãžã®å€æŽã¯ã processModelã»ã¯ã·ã§ã³ã®è¿œå æã«allowDefinition = " MachineOnly "å±æ§ãèšå®ã ããŠããããã machine.configãã¡ã€ã«ã§ã®ã¿èš±å¯ã ããŸãã
CïŒ\ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ Config \ Machine.config ïŒ
<section name="processModel" type="System.Web.Configuration.ProcessModelSection, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" allowDefinition="MachineOnly" allowLocation="false" />
web.configã䜿çšããŠåã¢ããªã±ãŒã·ã§ã³ã®processModelã»ã¯ã·ã§ã³ã®å€ãåå¥ã«èšå®ã§ããããã«ããã«ã¯ãããããã£allowDefinition = " Everywhere "ãèšå®ããå¿ èŠããããŸãã
WebãµãŒããŒããæ§æèšå®ãååŸããŸã
<system.web> <processModel autoConfig="False" maxWorkerThreads="100" maxIoThreads="100" minWorkerThreads="50" minIoThreads="8" /> <httpRuntime minFreeThreads="640" minLocalRequestFreeThreads="96"> </system.web> <system.net> <connectionManagement> <add address = "http://__1" maxconnection = "5000" /> <add address = "http://__2" maxconnection = "5000" /> </connectionManagement> </system.net>
éèŠïŒå€æŽãè¡ã£ãåŸãã¢ããªã±ãŒã·ã§ã³ããŒã«ãæŽæ°ããå¿ èŠããããŸãã
ååãªCPUãªãœãŒã¹ãããå Žåãå¿ èŠãªå Žåã«ã®ã¿ãããã®ãã©ã¡ãŒã¿ãŒãå¢ããå¿ èŠãããããšã«æ³šæããŠãã ããã
WebãµãŒããŒã®ããã©ãŒãã³ã¹ãåæããã«ã¯ãããã©ãŒãã³ã¹ã¢ãã¿ãŒã§ASP.NETã«ãŠã³ã¿ãŒãèšå®ããããšããå§ãããŸãã
- ASP.NETã¢ããªã±ãŒã·ã§ã³\èŠæ±/ç§
- WebãµãŒãã¹\ ISAPIæ¡åŒµãªã¯ãšã¹ã/ç§
- ASP.NET \çŸåšã®ãªã¯ãšã¹ã
- ASP.NET \ Requests Queued
- ASP.NET \æåŠããããªã¯ãšã¹ã
- ASP.NETã¢ããªã±ãŒã·ã§ã³\èŠæ±ã®å®è¡
- ASP.NETã¢ããªã±ãŒã·ã§ã³\èŠæ±ãã¿ã€ã ã¢ãŠãããŸãã
- ASP.NET \èŠæ±å®è¡æé
IISã¢ããªã±ãŒã·ã§ã³ããŒã«ãæäŸããw3wp.exeããã»ã¹ã®è©³çŽ°ãªåæã«ã€ããŠã¯ã Windows Software Development KitããWinDbgãããã¬ãŒãè©Šãããšãã§ããŸãã
ã«ãŠã³ã¿ã確èªããåŸãã·ã¹ãã ã®æ§æã調æŽããå¿ èŠãããå ŽåããããŸãã
ãªãã·ã§ãã«
IISã®ç解ãæ·±ããããã«ããã®äŸ¿å©ãªèšäºãIISã¢ãŒããã¯ãã£ã®åºç€ããŸãã¯ASP.NETã®ã¯ãšãªæäŸã㧠ããŠãŒã¶ãŒã®ãã©ãŠã¶ãŒããASP.NETã¢ããªã±ãŒã·ã§ã³ã®æçµããŒã«ãžã®ãªã¯ãšã¹ããåŠçããããã»ã¹ãããç解ããããšããå§ãããŸãã
IIS8ã䜿çšããå Žåã ãæ¬æ ŒçãªCPUè² è·èª¿æŽïŒCPU調æŽïŒãã«æ³šæãæãå¿ èŠã¯ãããŸããã
ãããã«
ãµãŒããŒåŽã§é »ç¹ã«ãããã¯ãŒã¯èŠæ±ãè¡ããªããµã€ãã§ã¯ãæšæºã®ããŒã«èšå®ã§ååã§ãïŒprocessModel / autoConfig =â trueâïŒã åæã«ãIISã¯ã³ã¢ããã20ã®ã¯ãŒã«ãŒã¹ã¬ãããš12ã®ãªã¢ãŒãæ¥ç¶ã®å¶éãèšå®ããŸãã ãããã®å€ãè¶ ãããšããªã¯ãšã¹ãããã¥ãŒã€ã³ã°ãéå§ããWebã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ãäœäžããŸãã
ãµã€ããæ£åžžã«æ©èœããã·ã¹ãã ã®æšå®è² è·ãæšå®ã§ããå Žåã¯ãäœãå€æŽããªãã§ãã ããã ããŸããŸãªãµãŒãã¹ãžã®ãªã¯ãšã¹ããåŠçããéã«ãããªãŒãºããéå§ããå Žåãããã«ãã¹ãŠã責ããã¹ãã§ã¯ãããŸããïŒ ASP.NETã®åºæ¬æ§æãå€æŽããããšããå§ãããŸãã ã¢ããªã±ãŒã·ã§ã³ããŒã«ã®åºæ¬èšå®ãå€æŽãããšã確ãã«ããã»ããµã®è² è·ãå¢å ããããšã«æ³šæããŠãã ããã ãã¹ãŠã®ã·ã¹ãã ãã©ã¡ãŒã¿ã®æé©ãªãã©ã³ã¹ã¯ãæ©åšã®å®å®ããçç£çãªæäœã®éµã§ãã ããšããã«ããããã«ããäºåã«èŠåãããããšã¯æŠè£ ããããšãæå³ããŸãã
Windows Serverãã©ãããã©ãŒã ã§ã®éçšWebãµãŒããŒã®éçšã®èšå®ãšæé©åã«é¢ããçµéšãå ±æããŠãã ããã
åç §è³æ
- 第17ç« -.NETã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ã®ãã¥ãŒãã³ã°
- WebãµãŒãã¹ãåŒã³åºããšãã®ç«¶åãããã©ãŒãã³ã¹ã®äœäžãããã³ãããããã¯
- ASP.NETã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ãã¥ãŒãã³ã°ãšæé©å
- 第15ç« -.NETã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ã®æž¬å®
- MSDNïŒProcessModelSectionã¯ã©ã¹