ã¾ããã
2015/9/26ã«ISUCON5äºé¸ã«åå ãã¾ããã
ãã®è¨äºã¯èªãã§å½¹ã«ç«ã¤ãããªãã¨ã¯ãªãããã ã®ææ³è¨äºã§ãã
ISUCON5äºé¸ã«åå ããã¾ã§
ISUCONã®åå¨èªä½ã¯å»å¹´ãããããæ°ã«ãªã£ã¦ããã®ã§ãããåå ãããã¨ãã¯ãªãã¦ããããã人ãã¡ããããªã¼ããããã«é¢é£è¨äºãªã©ãçºãã¦ããç¨åº¦ã
Â
ä»å¹´ãISUCONãããã®ãç¥ã£ã¦ããã®ã§ãååã¨åå ãããããªã¼ã¨æããã¨ããã£ããã©ããªãã¨ãªãèªããªããªã¼ã¨ãæã£ã¦ããããªãã
id:koemu ããããã
id:sugamasao ããã¨ISUCONåºããã ãã©ãä¸ç·ã«åºã¾ãããï¼ãçãªãèªããããã ããã
Â
YAPC::Asiaã§çµæ§ãªãã£ãã®é¨å±ãåãã¦ããkoemuãããããã¼ãã§ã¯ã
Rubyããããã¼ãã§ã¯ã
Ruby on Railsãã®èè
ã®ä¸äººã§ãããsugamasaoããã¨çµãã ã¨ãã¦ããããããããããã£ã¦ããã©ãããã¨ãã£ã¦å¼·ã¿ããªãèªåã«ä½ãã§ãããã ãããã¨æ©ã¿ã¤ã¤ããã®æ©ä¼ãéããããªãã¨ããæãã§ãã¼ã ã«ããã¦ããã£ãã
Â
åå ã決ã¾ã£ã¦ããã¯Slackã§ã®ããã¨ããä¸å¿ã§ããã¼ã åãå¿ ã§ç¼é
ã飲ãã§ãã人ãã¡ãã決ããããäºé¸ã®æ¥ç¨ã調æ´ããããã¦ããæ°ãããã
Â
ããããã°æ±ºèµ·ä¼ã¨ç§°ãã¦ä¸åº¦é£²ã¿ã«è¡ã£ãã
ãã®æç¹ã§ãäºæ¹ã«ä¼ãã®ã¯ã¾ã 2åç®ãçµç¤ã¯ãªããkoemuããã«SHIROBAKOè¦ãã¨è¿«ã£ã¦ããsugamasaoããã®å§¿ãé®®æã«è¦ãã¦ããã
å½æ¥ã¾ã§
ã¨ããããäºç¿ããªããã¨ãããã¨ã§ãéå»åç°å¢ã
Vagrantã§ä½ã£ã¦ããã³ãæµããããã¾ã§ã¯ããã®ã§ããã
Vagrantã ã¨ã¹ããã¯çã«ã¾ã¨ããªãã³ããèµ°ããªãããªæ°ãããã®ã§ããã®ã¾ã¾ãã°ããæ¾ç½®ãã¦ãã
Â
ãã®ãã¨ã¯æ¥åãä¸æ°ã«å¿ãããªã£ããã§æéã空ãã¦ãã¾ããçµå±ã¾ã¨ãã«è§¦ã£ãã®ã¯äºé¸ã®ä¸é±éåãããã§ãISUCON3äºé¸ã®AMIãm3.xlargeã§ãã¦ã¦ãã£ã¦ã¿ãã
ç¡åæãæããäºç¿
ã ããã3æéãããæéãã¨ã£ã¦ãã¢ããªã«ã¯æãåºããã«
ããã«ã¦ã§ã¢å¨ãã ãã§ãããããã£ã¦ã¿ããçµå±2452->3348ãéçã
koemuãããäºç¿ã§ããªãã®ã¹ã³ã¢ãåºãã¦ããã®ãç¥ã£ã¦ããã®ã§ãèªåã®çµæã®åºãªãå æ¸ã«ããªãç¦ã£ãã
Â
sugamasaoãããããã®ã§
Rubyã ããã¨ãããã¨ã§ãè¨èªã¯
Rubyãé¸ãã ã¨ãããGemã®ãã¼ã¸ã§ã³ãããã¤ãå¤ãã£ãã®ãåé¡ã ã£ãããããåæå®è£
ããã®ã¾ã¾åããªãã¦ã¤ã³ã¿ã¼ãããã®åªãã人ã«å©ããããã
Â
å½æ¥ã®åæå®è£
ããã®ã¾ã¾åããªããã¨ã¯ãªãã ããã¨æã£ã¦ããã©ããããã£ããã©ãã«ã§æéãæã£ã¦ããã¦ãããã¡ã«ä½æ¥æéãæ¸ããã ãããªã¨æãã¤ã¤ããã®ç¨åº¦ã®
Rubyåã§ã©ããããã èªåãã¨æã£ã¦ãããããã®æ©ã¯å¤¢ã§ISUCONã«ããªããã(夢ã®å
容ã¯è¦ãã¦ãªã
Â
äºé¸ã®åã
æ¥ãããã«ãkoemuããã
GCPã®ããã¸ã§ã¯ããªã©ãä½ã£ã¦ããã¦ããã®ã§ãå人ã¢ã«ã¦ã³ãã§GCEã®ã¯ã¤ãã¯ã¹ã¿ã¼ãã ããã£ã¦ãããã
Â
åGCEã ã£ãã®ã§ãã¯ã¤ãã¯ã¹ã¿ã¼ãã¯ãã£ã¦ããã£ãã¨ã¯æããã©ãgcloudã³ãã³ããããããªããããçµå±äºé¸ã§ãgcloudã³ãã³ãã¯ã»ã¨ãã©ä½¿ãã
sshãã¦ããã
äºé¸å½æ¥
éå§ã¾ã§
å½æ¥ã¯9:30ã«koemuããå®
ã§éã¾ã£ã¦ãããã¨ã«ãªã£ã¦ããã®ã§ãå¹³æ¥ããã¡ãã£ã¨æ©èµ·ããæ©èµ·ãæåããã¨ãããã楽ãã¿ãªã®ã¨ç·å¼µã§ãã¾ãå¯ããªãã£ãã
Â
æ©èµ·ãããããã®ã§ãå°ãæ©ã家ãã§ã¦ç§»åããããé»è»ã®ä¹ãæãã«å¤±æãã¦é
å»ãããããä¹ãæããã¤ããã®é§
ã颯ç½ã¨ã¹ã«ã¼ããã¨ãã®é¢¨æ¯ã¯å¿ãã¾ãã
Â
ãªãã ããã ã§éåãã¦ããã¼ãããã¼ã¿ãããªé°å²æ°ã ã£ãã¨ããã§ãéå¶ããåæ¥ã®äºé¸ã¯äºå®ããé
ãã¦11æéå§ã¨ããé£çµ¡ãå
¥ã£ãã
Â
çªç¶1æé空ãã¦ãã¾ã£ããã©ããã®æç¹ã§ãäºäººã«ä¼ãã®ã¯ã¾ã ä¸åç®ãå¾
ã¡æéã§ãããã話ããã®ã¯ãèªåã«ã¨ã£ã¦ã¢ã¤ã¹ãã¬ã¤ã¯ã«ãªã£ãã®ã§è¯ãã£ãã
Â
ã¹ãã¼ãåè² ãªã®ã§å
±æéè¦ãæèãã¦å£°æããã¦ããã¨ããæ®æ®µã®éç¨ã ã£ããããããªããã©ãæ¬çª
ãããã°ã¯ISUCONãªãããããªããã£ã¦è©±ãªã©ããã¤ã¤ã11æããäºé¸éå§ã
äºé¸éå§
éå§ç´å¾ã¯ãã³ããã¼ã«ã¼äºã
ã¨ããapt-get upgradeãããåèµ·åå¾ã«ãã£ã¹ã¯ãroã§ãã¦ã³ããããã¨ããããããæ··ä¹±ããã£ããidobataãã»ã¨ãã©æ¯ãã¦ãªãã£ãã
Â
ã¨ããããæé ã«å¾ã£ã¦
ã¤ã³ã¹ã¿ã³ã¹ãèµ·åãã¦ãã¢ããªããã©ã¦ã¶ã§ç¢ºèªã§ããã®ã¯11:18ã ã£ãã
Â
ãã®æç¹ã§koemuããã¯etckeeperãChefã®æºåããã¦ãããsugamasaoããã¯ã¢ããªã±ã¼ã·ã§ã³ã³ã¼ãã
GitHubã«pushããã¨ããã¾ã§æéããæ¸ã¾ãã¦ãæ°ããã
Â
ãã³ãã®ãã¥ã¼ãè©°ã¾ã£ã¦ããã®ã§ãå¾
ã¡æéã§åèªãããã調æ»ãèªåã¯DBã®ãã¼ãã«æ§é ã¨ããã¼ã¿éãããã調ã¹ã¦ããã
Â
æåã®ã¹ã³ã¢ã¯210ã§FAILããã³ããã¼ã«ã¼ã«åé¡ãããã¨ããé£çµ¡ããã£ãããããã©ããã®FAILããã³ããã¼ã«ã¼ã®åé¡ã ã£ãã®ãã©ããã¯ä¸æã
Â
ãã®ãã¨ã¯Slackã®ãã°ãè¦ãã¨ããããã®ç§ä¼ã®ã¿ã¬ãnginxã¢ãããã¼ãã
unicornã®ããã»ã¹æ°èª¿æ´ãªã©ããã¤ã¤ãã¨ã©ã¼ç¡ãã®ãã³ãçµæã¯766ãç§ä¼ã®ã¿ã¬ã£ã¦ããããªã¨ã¤ãã¥ãæã£ãã
Â
ããããã¯koemuããã
ããã«ã¦ã§ã¢å¨ããsugamasaoãããã¢ããªå¨ããè¦å§ããã®ã§ãèªåã¯ãã°ãããã³ããã¼ã«ã¼ãã©ããªãªã¯ã¨ã¹ããã©ããããæãã¦ãããè¦ãããã¦ãããã®æç¹ã§ã¯ãã¾ãã¢ããªã±ã¼ã·ã§ã³ã«æãå
¥ãã¦ãªãã£ãæ°ãããã
Â
13:16ãããã«2188ãåºãã¦ãä¸æçã«ç´¯è¨ãææ°ã¨ãã«1ä½ã«ãªã£ãã®ãããããã£ãã
Â
koemuãããkataribeãåãããããã«ãã¦ããã¦ããã®ã§ãkataribe, MySQLTuner,pt-query-digestã¨ã
MySQLã®ããã©ã¼ãã³ã¹
ã¹ãã¼ããè¦ã¤ã¤ããã³ããæµãããhtopã§CPUã¨ã¡ã¢ãªã®ä½¿ãã£ã·ããçºãã¦å¯¾å¿ç®æã決ãã¦ãã£ãã
Â
ããããã°ããã¡ã®ãã¼ã å
ã§AppArmorãçå¨ãæ¯ãã£ã¦ããã®ã¯ãã®ãããã®ãã¨ã ã£ããããããªãã
Â
14:30ãããã«N+1åé¡ãåæã«ãããã¨ã«ããããæ°ã¥ããISUCONã¯ã¤ã³ãã©ãã¥ã¼ãã³ã°ã³ã³ãã¹ããããªãã¦ãWebã¨ã³ã¸ãã¢ã®ç·åæ¦ãªãã ã£ã¦ãã¨ãæãã¤ã¤ãtagomorisããããåé¡ä½ãã¾ããã¼ãã¿ãããªè©±ããã¦ããã
Â
ãã®ãããããã¢ããªã«ããããæãå
¥ãã¦ããã詳細ã¯åé¡ãã¾ã å
¬éããã¦ãªãããæ¸ããªããã©ãããã¼ããããããã¿ãããªãã®ããããããã¯ãªãã ãwãã¿ãããªãã®ããã£ã¦é¢ç½ãã£ãã
Â
éããå¦çã
SQLããå®è£
ã®å¤æ´ãã¤ã³ããã¯ã¹ã®èª¿æ´ã§æ½°ãã¤ã¤ãã¨ããã¿ã¤ãã³ã°ã§çµæã ãè¨ãã°2æ¥éãã§è¦ã¦ãäºé¸çªç ´ã¬ãã«ã®ã¹ã³ã¢ãæ¥ã«åºã¦æ¹§ãããã©ããã¶ãããã¯ãã³ããã¼ã«ã¼ã®éãçªãããªã«ãã ããã¨ãã話ã«ãªãããã®å¤æ´ã¯å
ã«æ»ããã
Â
ããç¨åº¦ãN+1ãæ½°ãããããã§é »çºãã
SQLã
MemcachedãRedisã§æãããã¨ãã話ã«ãªã£ãã
Â
Memcachedã¯è§¦ã£ããã¨ãããã©æ¥åã§ã»ã¨ãã©ä½¿ã£ããã¨ãªãã£ãããRedisã¯ä½¿ã£ã¦ããã©ã»ãã·ã§ã³ã¹ãã¬ã¼ã¸ã¨ãã¦ãã使ã£ã¦ãªããããããElastiCacheã ããè¨å®ãããç¥ããªããã§ä¸å®ã¯å°ããã£ããã©ã20-30åãã£ã¦ã¿ã¦ãã¡ããã ã£ããç¸è«ããã¨å®£è¨ãã¦ãã£ã¦ã¿ãã
Â
Rubyistã®sugamasaoãããããã®ã§ãGemã®é¸æãªã©ã§è¿·ããªãã¦æ¸ãã ããå®è£
ã®ã¢ããã¤ã¹ã¨ããæ¹åã®PRã¨ããããã£ãããã¦ã¨ã¦ãå©ãã£ããããªã«ããåå¼·ã«ãªã£ãã
Â
1æéå¼±ããã£ããã©å®è£
ã§ãã¦ããã®éåèªä½æ¥ããã¦ãããã®ãå«ãã18æãããã§ã¹ã³ã¢ã¯4500åå¾ã¾ã§ä¸ãã£ãã
Â
æå¾ã®30åã¯åèµ·åãã¦ãã¹ãã¨æ±ºãã¦ããã®ã§ã18:30ã¾ã§ã¯ãã¾ãæ¿ããå¤æ´ã¯ãããã¡ã¾ã¡ã¾ã¨å°ããªæ¹ä¿®ããã¦ã18:30ã¡ãã£ã¨éãã¦ããåèµ·åãã¹ãã
Â
å¤åã«ãããåèµ·åããããã¾ããããªãã¨ããããã£ã¦ãkoemuãã調ã¹ã¤ã¤ã¬ã¼ãã¨ç´ãã¦ããã®ãã¿ã¦ããã®äººåºåãããªã¼ã¨æã£ãã
Â
ãªãã¨ãåèµ·ååé¡ã解決ãããã©ã確ãæå¾ã®ãã³ãã¯æµããã¨ãã§ããã«æéåãã
äºé¸çµäºå¾
ããã®ãã³ã·ã§ã³ã§8æéãä½æ¥ããã®ã£ã¦å¹´ã«ä¸åº¦ãããã©ããã®å¤§é害ãããã§ãããã¨ãããããã¨å¤ããã¦ãã¤ã¬è¡ãã®å¿ãããã¨ã話ããããã¦ãã
Â
çµãã£ã¦ã¿ãã¨ããããã¯ãã£ã¨ããããæ¹åã§ãããªã¼ã¨ãæã£ããã©ãè£ãè¿ãã°ãåå ããã®ã決ããã¨ãã¯ä½ãã§ããªãããããªããã¨ããä¸å®ã§ãã£ã±ãã ã£ãã®ã§ãä½ããããã¼ã ã®çµæã«è²¢ç®ã§ãããããªæ°ããã¦ããã£ãã¨æã£ã¦ããæ°ãããã
Â
ãã®ãã¨ã¯3人ã§ç¼èé£ã£ã¦ããã¼ã«ã¨ã飲ãã§ããããã話ããã¦å¸°ã£ãã
ãããã«
å¾ä½ã®ç¥ããªãã·ã¹ãã ãç¸æã«ããã¨ããã®ã¯ãWebã®ä¸çã§ä»äºããã¦ããã°ãã£ã¨èª°ã«ã§ãããããããã©ã¼ãã³ã¹ã®åé¡ãçªãæ¢ãã¦ã¤ã³ãã©ã¨ã¢ããªããã¾ã使ã£ã¦è§£æ±ºããã¨ããã®ãããããªãã«çé¢ç®(ï¼)ã«ãã£ã¦ããã¨ã³ã¸ãã¢ã«ã¨ã£ã¦ã¯ãããããã¨ã ã¨æãã
Â
ã§ããããã8æéã¨ããéãããæéã§ããããæ¹åçµæããã³ããã¼ã«ã¼ãæ°åã¨ãã¦æ確ã«åºãã¦ãããããªæ©ä¼ã¯ISUCONããããããªãããããªãããªã¨æã£ãã
Â
ã¾ããå人çã«ã¯koemuãããsugamasaoããã¨ä¸ç·ã«åå ã§ãã¦ããäºäººã®ã¢ããã¼ãã®ä»æ¹ãéè¿ã§è¦ãªããä½æ¥ã§ããã®ããã¨ã³ã¸ãã¢ã¨ãã¦åºæ¿ã«ãªã£ãããããæå³ã§ã®ç¦ããæããããäºäººã«ã¯ã¨ã¦ãæè¬ãã¦ã¾ãã
Â
å§åçãªã¹ã³ã¢ã§å·®ãè¦ãã¤ãã¦ãããæ¬æ¦åºå ´è
ã®ã¬ãã³ã³ããã«ãã¨ã¦ã楽ãã¿ã
éå¶ã®ã¿ãªãã¾ãããã¨ããããã¾ããã
Â
æå¾ã«ããããã«æ¥½ããã«ã¨ããåçãè²¼ã£ã¦ãããã
ä½è«
- ä»åISUCONã«åå ãããã£ããã¯ãå
ããã©ãã°YAPC::Asia 2015ãYAPCã¯ã»ãã·ã§ã³ã®æ¥½ããããããã¨ãªãããããããã¤ãªãããçã¾ãããããªã¨ããã§ããã£ããã ãªã¼
- GCEãããã£ãã®ã§ãã¾ãã©ããã§ä½¿ã£ã¦ã¿ãã
- ã¯ã¦ãã¯ãã¾ã«ä½¿ã£ã¦ããã©ãã¯ã¦ãªããã°ã¯ãã®è¨äºãæ¸ãããã«ä»æ¥ä½ã£ã