Hacking Apache HTTP Server at Yahoo!
é ãã°ããªãã Hacking Apache HTTP Server at Yahoo! ãä¸éãèªã¿ã¾ããããã㯠Yahoo! ã®ã¨ã³ã¸ãã¢ã§ãã Michael J. Radwin æ°ãæ¨å¹´æ«ã® ApacheCon ã§åã£ãã¨ãã®ã¹ã©ã¤ãã
Yahoo! ã Apache ã«ç¬èªã«æãå ¥ãã "yapache" ãªã Apache ã使ã£ã¦ãã¨ããã®ã¯ã¨ãã©ãèãã¦ããã§ãããå ·ä½çã«ã©ãããå¤æ´ãå ¥ã£ã¦ããã¨ãã¯è¬ã®ã¾ã¾ã§ããããã®ã¹ã©ã¤ãã«ã¯ãã®è¾ºãã®è©±ãæããããªãæ¸ãã¦ãã£ã¦ãã¨ã¦ãé¢ç½ãã
ã·ã°ãã«ã使ããªãã§ãã°ããã¼ãã¼ã·ã§ã³ããã¨ãããã°ãã©ã¼ãããã工夫ãã¦ãã¨ããåºåã® HTML ã«ãã¹ãåãªã©ãè¨è¼ãã¦ããã¦ãµãã¼ãã«å½¹ç«ã¦ãã¨ããããããåèã«ãªãç¹ã¯å¤ãã£ãã®ã§ãããä¸çªèå³ãå¼ãããã®ã¯ãã¯ã "Waiting for the Client Sucks" ã®è¾ºããOS ã Apache ã®æåã«æã¾ãããããã¡ãªã³ã°ã®å±¤ã¨ã¿ãªãã¦æ´»ç¨ãã¦ãApache ã«ã¯ãã¤ãããã¯ã³ã³ãã³ããåºåããã ãã«å°å¿µãããããããã¡ãªã³ã°ã¯ OS ã«ãããããã¿ãããªè©±ãæ¸ãã¦ã¾ãã
FreeBSD ã® httpready ãªããã£ã«ã¿ã使ã£ã¦ãHTTP ãªã¯ã¨ã¹ããã«ã¼ãã«å´ã§ä¸ç«¯ãããã¡ãªã³ã°ããApache ã¯ãããã¡ããã¾ã¨ãã¦ãªã¯ã¨ã¹ãã®å
容ãåå¾ãããããã¨ããªã¯ã¨ã¹ãå
¨ä½ãæåã® read()
ã§ã¾ã¨ãã¦èªããã¨ãã§ãã¦ãApache ã®ããã»ã¹ããªã¯ã¨ã¹ããèªã¿åãã¾ã§ã®éã«å æãããæéããªããªããçµæã¨ãã¦ãªã½ã¼ã¹ãæå¹æ´»ç¨ã§ãããã£ã¦ãªãã¨ãæ¸ãã¦ã¾ãã
httpready ã£ã¦ããã®ã¯ãApache ã«æ¨æºã§çµã¿è¾¼ã¾ãã¦ãã AcceptFilter ã®ãã¨ããããFreeBSD ã®ã«ã¼ãã«ã®æ©è½(?) ã® accf_http ãæå¹ã«ãªã£ã¦ãã¨ä½¿ãã AcceptFilter ã§ããããè¨å®ãã¦ããã¨ã«ã¼ãã«ã§ã® HTTP ãªã¯ã¨ã¹ããããã¡ãªã³ã°ãå¹ãããã§ãããªããApache ã®ããã¥ã¡ã³ãæ°ããLinux ã® TCP 層ã«ã¯åä¸ã®ãã¨ãããå®è£ ã¯ãµãã¼ãããã¦ããªãããã§ãã
Linux ã® TCP_DEFER_ACCEPT 㯠HTTP ãªã¯ã¨ã¹ãã®ãããã¡ãªã³ã°ããµãã¼ããã¦ãã¾ãããnone 以å¤ã®å¤ã§TCP_DEFER_ACCEPT ãæå¹ã«ãªãã¾ãã詳細ã«ã¤ãã¦ã¯ Linux man ãã¼ã¸ tcp(7) ãåç §ãã¦ãã ããã
ã«ã¼ãã«ã¬ãã«ã§ã®ãããã¡ãªã³ã°ããµãã¼ããã¦ããªããã¨ã¯ããã¾ããå®éã« Linux ããã®ã¨ãã©ããã風ã«åãã¦ããã¾ã§ã¯è¨åããã¦ãªãã®ã§ããã®è¾ºã¯ãããããã¾ããã
ã¾ããåãä»ãããªã¯ã¨ã¹ãã ãã§ãªããåºåå´ã®ãããã¡ãªã³ã°ã«ã工夫ããã¦ããããã§ãFreeBSD ãªã kern.ipc.maxsockbuf
ãLinux ãªã net.core.wmem_default
㨠net.core.wmem_max
ã®å¤ãæã大ããªã¬ã¹ãã³ã¹ã®ãµã¤ãº (HTML + HTTPãããã®ãµã¤ãº)ã¾ã§å¼ãä¸ãã¦ãOS å´ã®éä¿¡ç¨ã®ãããã¡éãå¢ããã¨ãããã¨ãããããã®ç¶æ
ã§ãã½ã±ããã®ãããã¡ã«ã¬ã¹ãã³ã¹ã®ãã¼ã¿ãã¾ã¨ãã¦æ¸ãè¾¼ãã§ãã£ã¦ãããã«ã½ã±ãããéããã¨ã(ãã®ã½ã±ããã®æ±ããã¹ã©ã¤ãã®ä¸ã§ã¯ NO_LINGCLOSE ã¨å¼ãã§ãæ§åã)ãããããã¨ã§ Apache ã®ããã»ã¹ãããã«ãã¼ã«ã«å¸°ãããã«ãªããå¹çãããã¨ã®ãã¨ã§ããã¯ã©ã¤ã¢ã³ããå
¨é¨ãåä¿¡ãããã©ããã¯ç¡è¦ã
ã½ã±ãããããã¡ã«ã¾ã¨ãã¦æ¸ãè¾¼ãã§ããã¯ãã¼ãºã¨ãã£ã¦ãã辺ãã¯ãApache ã®ã³ã¼ãã«ç´æ¥æãå ¥ãã¦å®ç¾ããã®ããªãã
OS ã®ãããã¡ãªã³ã°ã®æ©è½ãæ大éæ´»ãããã¨ããæ¹éã¯ããåããã¾ããããæ°ã«ãªã£ãã®ã¯ãªãã¼ã¹ãããã·ã¨ããåãã§ãå ´åã¯ã©ããªãã ãããªãã¨ããã¨ãããYahoo! ã§ã¯ããã©ã¼ãã³ã¹ãè¦æ±ãããæã§ã¯ Apache API ã使ã£ã¦ C ã§ã¢ããªã±ã¼ã·ã§ã³ãè¨è¿°ãããããã®ã§ãããããããã¨ãã®ã¢ããªã±ã¼ã·ã§ã³ãç©ãã Apache ãç´æ¥ã¯ã©ã¤ã¢ã³ãã«å¿çãããã¨ã«ãªã£ã¦ãOS ãã¯ã©ã¤ã¢ã³ã㨠Apache ã®éã«æã¾ããããã¡ãªã³ã°ã®å±¤ã¨ã¿ãªããã¨ãã§ãã¾ãã
ä¸æ¹ããªãã¼ã¹ãããã· + mod_perl ã®ãããªç°å¢ã§ã¯ãªãã¼ã¹ãããã·ããããã¡ã®å½¹å²ãæããã¾ãããªãã¼ã¹ãããã·ã®ããã©ã¼ãã³ã¹ãç®ä¸æ¯ããããã¨ããæã«ã¯ yapache ã®èãæ¹ãå¿ç¨ã§ãããã§ãããããã¯ã¨ã³ãã«æ§ãã mod_perl ãè¼ã£ã¦ã OS ã«ã¯ã©ããããã¥ã¼ãã³ã°ãå ããã®ãçæ³çãªã®ããmod_proxy ã¨ããã¯ã¨ã³ãã®ãµã¼ãã¼ãé«é㪠LAN ã§ç¹ãã£ã¦ãç°å¢ã§ããHTTP ãªã¯ã¨ã¹ãã®ã«ã¼ãã«ã¬ãã«ã§ã®ãããã¡ãªã³ã°ã¯å¹æçãªã®ãããã®è¾ºè©³ããè¨è¿°ãã¦ããã®ã¨ãã¯ãªãããªãPractical mod_perl ã«ã¯ã«ã¼ãã«ãã©ã¡ã¼ã¿ã®ãã¥ã¼ãã³ã°æ¹æ³ã¨ããè¥å¹²è¼ã£ã¦ãæ°ããããã©ãããã¾ã§çªã£è¾¼ãã ãã¨ã¯æ¸ãã¦ãªãã£ããããªæ°ããããã¡ãã£ã¨èªã¿è¿ãã¦ã¿ããã