ã¯ããã«
ãã®ã·ãªãŒãºã®ç¬¬1åã§ã¯ã WSGIã®äœè ã«ãããšã WSGIãš6ã€ã®æã人æ°ã®ãããµãŒããŒã«äŒããŸããã ãã®ããŒãã§ã¯ããããã®ãµãŒããŒã®ããã©ãŒãã³ã¹ãåæããçµæã衚瀺ãããŸãã ãã®ç®çã®ããã«ãç¹å¥ãªãã¹ããµã³ãããã¯ã¹ãäœæãããŸããã
åºå Žè
æéã®å¶çŽã®ããã調æ»ã¯6ã€ã®WSGIãµãŒããŒã«éå®ãããŠããŸããã ãã®ãããžã§ã¯ãã®èµ·åæé ã¯ãã¹ãŠGitHubã§ãã¹ããããŠããŸã ã ããããæéã®çµéãšãšãã«ããããžã§ã¯ãã¯æ¡å€§ããä»ã®WSGIãµãŒããŒã®ããã©ãŒãã³ã¹åæãæ瀺ãããã§ãããã ãã ããä»ã®ãšããã6ã€ã®ãµãŒããŒã«ã€ããŠèª¬æããŸãã
- Bjoernã¯èªèº«ããè¶ é«éWSGIãµãŒããŒããšè¡šçŸãããæéãæå°ãæ軜éã®WSGIãµãŒããŒãã§ããããšãèªã£ãŠããŸãã ããã©ã«ãã®ã©ã€ãã©ãªèšå®ã®ã»ãšãã©ã䜿çšããå°ããªã¢ããªã±ãŒã·ã§ã³ãäœæããŸããã
- CherryPyã¯éåžžã«äººæ°ã®ããå®å®ãããã¬ãŒã ã¯ãŒã¯ããã³WSGIãµãŒããŒã§ãã ãã®å°ããªã¹ã¯ãªãã㯠ã CherryPyãä»ããŠãµã³ãã«ã¢ããªã±ãŒã·ã§ã³ãæäŸããããã«äœ¿çšãããŸããã
- Gunicornã¯ãRubyã®UnicornãµãŒããŒïŒååã®ç±æ¥ïŒã«è§ŠçºãããŸããã 圌ã¯ããããç°¡åã«å®è£ ããã䜿ãããããããªãéãããšæ§ããã«äž»åŒµããŠããŸãã BjoernãCherryPyãšã¯ç°ãªãã Gunicornã¯ã¹ã¿ã³ãã¢ãã³ãµãŒããŒã§ãã ãã®ã³ãã³ãã䜿çšããŠäœæããŸããã WORKER_COUNTãã©ã¡ãŒã¿ãŒã¯ã䜿çšå¯èœãªããã»ããµãŒã³ã¢ã®æ°ã®2åã«1ãå ããå€ã«èšå®ãããŸããã ããã¯Gunicornããã¥ã¡ã³ãã®æšå¥šäºé ã«åºã¥ããŠè¡ãããŸããã
- Meinheldã¯ã軜éã§ãããšäž»åŒµããé«æ§èœã®WSGIäºæã®WebãµãŒããŒã§ãã ãµãŒããŒãµã€ãã«ç€ºãããŠããäŸã«åºã¥ããŠã ã¢ããªã±ãŒã·ã§ã³ãäœæããŸããã
- mod_wsgi㯠mod_pythonãšåãäœæè ã«ãã£ãŠäœæãããŸããã mod_pythonãšåæ§ã«ãApacheã§ã®ã¿äœ¿çšå¯èœã§ãã ãã ããå¯èœãªéãæå°ã®Apacheã€ã³ã¹ã¿ã³ã¹ãäœæãããmod_wsgi expressããšããããŒã«ãå«ãŸããŠããŸãã ãã®ã³ãã³ã㧠mod_wsgi expressãæ§æããŠäœ¿çšããŸããã Gunicornã«äžèŽããããã« ãããã»ããµã³ã¢ã®2åã®ã¯ãŒã«ãŒãäœæããããã«mod_wsgiã調æŽããŸããã
- uWSGIã¯ãã«æ©èœã®ã¢ããªã±ãŒã·ã§ã³ãµãŒããŒã§ãã ååãšããŠã uWSGIã¯ãããã·ãµãŒããŒïŒäŸïŒNginxïŒ ãšã€ã³ã¿ãŒãã§ã€ã¹ããŸãã ãã ããåãµãŒããŒã®ããã©ãŒãã³ã¹ãããé©åã«è©äŸ¡ããããã«ããã¢ãµãŒããŒã®ã¿ã䜿çšããŠã䜿çšå¯èœãªããã»ããµã³ã¢ããšã«2ã€ã®ã¯ãŒã«ãŒãäœæããããšããŸãã ã
ãã³ãããŒã¯
ãã¹ããå¯èœãªéã客芳çã«ããããã«ã Dockerã³ã³ãããäœæããŠããã¹ã察象ã®ãµãŒããŒãã·ã¹ãã ã®ä»ã®éšåããåé¢ããŸããã ãŸããDockerã³ã³ããã䜿çšããããšã§ããã¹ãŠã®èµ·åãæåãã確å®ã«éå§ãããŸãã
ãµãŒããŒïŒ
- Dockerã³ã³ããã§éé¢ãããŸãã
- å²ãåœãŠããã2ã€ã®ããã»ããµã³ã¢ã
- ã³ã³ããã®RAMã¯512 MBã«å¶éãããŠããŸããã
ãã¹ãïŒ
- ææ°ã®HTTPãã³ãããŒã¯ããŒã«ã§ããwrkããã¹ããå®è¡ããŸããã
- ãµãŒããŒã¯ã©ã³ãã ãªé åºã§ãã¹ããããåææ¥ç¶æ°ã¯100ã10,000ã®ç¯å²ã§å¢å ããŸããã
- wrkã¯ãDockerã䜿çšããªã2ã€ã®CPUã³ã¢ã«å¶éãããŠããŸããã
- åãã¹ãã¯30ç§ç¶ãã4åç¹°ãè¿ãããŸããã
ã¡ããªãã¯ïŒ
- æ°žç¶çãªãªã¯ãšã¹ãããšã©ãŒãããã³é 延ã®å¹³åæ°ã¯wrkã«ãã£ãŠæäŸãããŸãã ã
- Dockerã«çµã¿èŸŒãŸããç£èŠã«ãããCPUãšRAMã®äœ¿çšã¬ãã«ã瀺ãããŸããã
- æé«å€ãšæäœå€ã¯ç Žæ£ãããæ®ãã®å€ã¯å¹³ååãããŸããã
- 奜å¥å¿ã®ããã«ãã¹ã¯ãªããå šäœãGitHubã«éä¿¡ããŸããã
çµæ
ãã¹ãŠã®åæããã©ãŒãã³ã¹ææšã¯ãããžã§ã¯ããªããžããªã«å«ãŸããŠããããµããªãŒCSVãã¡ã€ã«ãæäŸãããŠããŸããã ãŸããèŠèŠåã®ããã«ãã°ã©ãã£ãã¯ã¹ã¯Google-docç°å¢ã§äœæãããŸããã
RPS察åææ¥ç¶æ°
ãã®ã°ã©ãã¯ãåæãªã¯ãšã¹ãã®å¹³åæ°ã瀺ããŠããŸãã æ°å€ã倧ããã»ã©åªããŠããŸãã
- BjoernïŒæ確ãªåè ã
- CherryPyïŒçŽç²ãªPythonã§æžãããŠããã«ããããããã圌ã¯æé«ã®ããã©ãŒãã³ã¹ãçºæ®ããŸããã
- MeinheldïŒã³ã³ãããªãœãŒã¹ãä¹ããããšãèãããšããã°ãããã§ãã
- mod_wsgiïŒæéã§ã¯ãããŸããããããã©ãŒãã³ã¹ã¯äžè²«ããŠé©åã§ããã
- GunicornïŒããäœãè² è·ã§è¯å¥œãªããã©ãŒãã³ã¹ãçºæ®ããŸãããå€æ°ã®æ¥ç¶ã§ãã¬ãŒã¹ã§ããŸãã
- uWSGIïŒãã©ã¹ãã¬ãŒã·ã§ã³ããããçµæã¯è¯ããããŸããã
åè ïŒãã§ã«ã³
ãã§ã«ã³
絶ãéãªããªã¯ãšã¹ãã®æ°ã§ã ãã§ã«ã³ã¯æ確ãªåè ã§ãã ãããããã®æ°åã競åä»ç€Ÿã®æ°åããã¯ããã«é«ãããšãèãããšãç§ãã¡ã¯å°ãæççã§ãã Bjoernãæ¬åœã«é©ãã»ã©éããã©ããã¯ããããŸããã æåã«ãµãŒããŒãã¢ã«ãã¡ãããé ã«ãã¹ãããŸãããã Bjoernãäžåœãªåªäœæ§ãåŸããšèããŸããã ãã ãããµãŒããŒãã©ã³ãã ãªé åºã§ãµãŒããŒãèµ·åããŠåãã¹ãããåŸã§ããçµæã¯å€ãããŸããã
uWSGI
uWSGIã®åŒ±ãçµæã«å€±æããŸããã 圌ãå é ã«ç«ã€ããšãæåŸ ããŠããŸããã ãã¹ãäžã«ã uWSGIãã°ãç»é¢ã«åºåãããããšã«æ°ä»ããæåã«ãµãŒããŒãè¡ã£ãè¿œå äœæ¥ã§ããã©ãŒãã³ã¹ã®äžè¶³ã説æããŸããã ãã ããã-- disable-logging ããªãã·ã§ã³ãè¿œå ããåŸã§ãã uWSGIã¯äŸç¶ãšããŠæãé ããµãŒããŒã§ãã
uWSGIããã¥ã¢ã«ã§è¿°ã¹ãããã«ãéåžžã¯Nginxãªã©ã®ãããã·ãµãŒããŒãšã€ã³ã¿ãŒãã§ã€ã¹ããŸãã ããããããããã®ãããªå€§ããªéãã説æã§ãããã©ããã¯ããããŸããã
é 延
é 延ã¯ãèŠæ±ãšãã®å¿çã®éã®çµéæéã§ãã æ°å€ãå°ããã»ã©åªããŠããŸãã
- CherryPyïŒè² è·ãé©åã«åŠçããŸããã
- BjoernïŒäžè¬çã«åŸ ã¡æéã¯çãã§ãããåææ¥ç¶ãå°ãªãæ¹ãããŸãæ©èœããŸãã
- GunicornïŒäžè²«æ§ããããŸãã
- mod_wsgiïŒå€æ°ã®åææ¥ç¶ãããå Žåã§ãå¹³åããã©ãŒãã³ã¹ã
- MeinheldïŒå šäœçã«ã蚱容å¯èœãªããã©ãŒãã³ã¹ã
- uWSGIïŒuWSGIã¯åã³æåŸã®å Žæã«ãªããŸããã
åè ïŒCherryPy
RAM䜿çšé
ãã®ã¡ããªãã¯ã¯ãåãµãŒããŒã®ã¡ã¢ãªèŠä»¶ãšãæ床ãã瀺ããŸãã æ°å€ãå°ããã»ã©åªããŠããŸãã
- BjoernïŒéåžžã«è»œãã§ãã 10,000 MBã®åæãªã¯ãšã¹ããåŠçããããã«9 MBã®RAMãã䜿çšããŸããã
- MeinheldïŒ Bjoernãšåãã§ãã
- GunicornïŒããããªã¡ã¢ãªæ¶è²»ã§é«è² è·ã«å·§ã¿ã«å¯ŸåŠããŸãã
- CherryPyïŒæåã¯å°éã®RAMãå¿ èŠã§ããããè² è·ãå¢å ããã«ã€ããŠäœ¿çšéãæ¥éã«å¢å ããŸããã
- mod_wsgiïŒäœãã¬ãã«ã§ã¯ãã¡ã¢ãªå ã§æãæ¿ãããã®ã®1ã€ã§ããããããªãäžè²«ãããŸãŸã§ããã
- uWSGIïŒæããã«ãç§ãã¡ããã¹ãããŠããããŒãžã§ã³ã«ã¯ãæ¶è²»ãããã¡ã¢ãªã®éã«åé¡ããããŸãã
åè³è ïŒBjoern and Meinheld
ãšã©ãŒæ°
ãšã©ãŒã¯ããµãŒããŒãã¯ã©ãã·ã¥ãããšããäžæãããšãããŸãã¯èŠæ±ãã¿ã€ã ã¢ãŠããããšãã«çºçããŸãã äœãã»ã©è¯ãã
ãµãŒããŒããšã«ããªã¯ãšã¹ãæ°ãšãšã©ãŒæ°ã®åèšæ¯ã®æ¯çãèšç®ããŸããã
- CherryPyïŒæ¥ç¶æ°ãå€ãå Žåã§ãããšã©ãŒçã¯çŽ0ã§ãã
- BjoernïŒãšã©ãŒãçºçããŸããããããã¯åŠçããããªã¯ãšã¹ãã®æ°ã«ãã£ãŠçžæ®ºãããŸããã
- mod_wsgiïŒèš±å®¹ãšã©ãŒç6ïŒ ã§è¯å¥œã«æ©èœããŸãã
- GunicornïŒ9ïŒ ã®ãšã©ãŒçã§åäœããŸãã
- uWSGIïŒåŠçããããªã¯ãšã¹ãã®æ°ãå°ãªãããšãèãããšã34ïŒ ã®ãšã©ãŒçã§çµãããŸããã
- MeinheldïŒæãè² è·ã®é«ããã¹ãäžã«10,000ãè¶ ãããšã©ãŒãæããããé«ãè² è·ã§èœã¡ãŸããã
åè ïŒCherryPy
CPU䜿çšç
ãµãŒããŒãæ£åžžã«åäœããŠããå ŽåãCPU䜿çšçãé«ããŠãæªãããªãã ãã ããããã¯ãµãŒããŒã«é¢ããããã€ãã®èå³æ·±ãæ å ±ãæäŸããŸãã 2ã€ã®CPUã³ã¢ã䜿çšããããããå¯èœãªæ倧䜿çšçã¯200ïŒ ã§ãã
- BjoernïŒ100ïŒ CPUãäžè²«ããŠäœ¿çšããŠããããšããæãããªããã«ãã·ã³ã°ã«ã¹ã¬ãããµãŒããŒã
- CherryPyïŒãã«ãã¹ã¬ããã§ããã150ããŒã»ã³ãã§ã¹ã¿ãã¯ããŠããŸãã ããã¯ã Python GILãåå ã§ããå¯èœæ§ããããŸãã
- GunicornïŒäœãã¬ãã«ã§CPUãªãœãŒã¹ããã«ã«äœ¿çšããŠãããã€ãã®ããã»ã¹ã䜿çšããŸãã
- MeinheldïŒBjoernãªã©ã®CPUãªãœãŒã¹ã䜿çšããã·ã³ã°ã«ã¹ã¬ãããµãŒããŒã
- mod_wsgiïŒãã¹ãŠã®æž¬å®ãéããŠãã¹ãŠã®CPUã³ã¢ã䜿çšãããã«ãã¹ã¬ãããµãŒããŒ
- uWSGIïŒCPU䜿çšçãéåžžã«äœãã CPUæ¶è²»ã¯50ïŒ ãè¶ ããŸããã ããã¯ãuWSGIãæ£ããæ§æãããŠããªã蚌æ ã®1ã€ã§ãã
åè ïŒããããããã¯ãããã©ãŒãã³ã¹ã®æ¯èŒãšãããããè¡åã®èŠ³å¯ã«è¿ãããã§ãã
ãããã«
ãŸãšãããšïŒ åãµãŒããŒã®çµæããåŒãåºãããšãã§ããäžè¬çãªã¢ã€ãã¢ã次ã«ç€ºããŸãã
- BjoernïŒãè¶ é«éãè¶ è»œéã®WSGIãµãŒããŒããšããŠæ£åœåããŸãã
- CherryPyïŒé«æ§èœãäœã¡ã¢ãªæ¶è²»ãäœãšã©ãŒçã çŽç²ãªPythonã«ãšã£ãŠæªãã¯ãããŸããã
- GunicornïŒäžè² è·ã«é©ãããµãŒããŒã
- MeinheldïŒããŸãæ©èœããæå°éã®ãªãœãŒã¹ã§æžã¿ãŸãã ãã ããé«è² è·ã«èŠåŽããŠããŸãã
- mod_wsgiïŒApacheã«çµ±åããããŸãæ©èœããŸãã
- uWSGIïŒéåžžã«å€±æããŸããã uWSGIã誀ã£ãŠèšå®ããããã€ã³ã¹ããŒã«ããããŒãžã§ã³ã«åºæ¬çãªãšã©ãŒããããŸãã