tl;dr;
ã¿ã¤ãã«ãå ¨ã¦
- tl;dr;
- ä»å¹´ã®æºå
- ãªãã¸ããª
- PRã¨Datadogãè¦ãªããå½æ¥ãã£ããã¨ãæ¯ãè¿ã
- å½æ¥10:00ã18:00ã®Datadogæã
- å
·ä½çã«ãã£ããã¨
- CloudFormationããèµ·åããç´å¾ã®ã¤ã³ã¹ã¿ã³ã¹ã«ãã³ããã¼ã«ã¼ãå®è¡ï¼ã¹ã³ã¢ï¼4148ï¼
- ãã¤ãã®ã¹ãããããã³ãã¼ãã¦åç §å®è£ ãGoããRubyã«å¤æ´ï¼ã¹ã³ã¢: 3781ï¼
- Sentryã¨ddtraceï¼Datadogã®APMï¼ãæå¹åï¼ã¹ã³ã¢ï¼3497ï¼
- rubocop-isuconå°å ¥ï¼ã¹ã³ã¢ï¼3389ï¼
- GET /api/user/:username/icon : DBã«ããç»åãéããï¼ã¹ã³ã¢ï¼3827ï¼
- fill_user_responseã§DBã®ç»åã使ããªãããã«ããï¼ã¹ã³ã¢ï¼4518ï¼
- 2å°ç®ã®ãµã¼ããDBå°ç¨ã¨ãã¦æå ¥ï¼ã¹ã³ã¢ï¼6893ï¼
- MySQLã®ã¹ãã¼ãã°ãç¡å¹åï¼ã¹ã³ã¢ï¼7028ï¼
- index追å ç¥ï¼ã¹ã³ã¢ï¼7132ï¼
- livecomment_modelãnilã£ã¦NoMethodErrorã«ãªã£ãã®ã§ä¿®æ£
- 3å°ç®æå ¥ï¼ã¹ã³ã¢ï¼7228ï¼
- 17:21é ã«åèµ·å試é¨
- appã1å°ã§åããåæã«ããï¼ã¹ã³ã¢ï¼6949ï¼
- æå¾ã«Datadogã¨ã諸ã ç¡å¹åï¼ã¹ã³ã¢ï¼10663ï¼
- æçµã¹ã³ã¢
- æ¥å¹´ã«åãã¦
ä»å¹´ã®æºå
ISUCONã®åã®é±ã« Google Cloud Next Tokyo â23 ã«ç»å£ããé¢ä¿ã§ä»å¹´ã®æºåæéã¯å®è³ª1é±éç¨åº¦ã§ããã
ã¨ããããåãåãæ»ãããã«ä¸è¨ã®ç´ æ¯ãããã¦ã¾ããã
ãªãã¸ããª
競æç¨ã®ãªãã¸ããª
ISUCONç¨ã®æ±ç¨Itamaeã¬ã·ãé
PRã¨Datadogãè¦ãªããå½æ¥ãã£ããã¨ãæ¯ãè¿ã
å½æ¥10:00ã18:00ã®Datadogæã
sinatraã®APM
競æä¸ã¯ãããè¦ãã®ãä¸çªå¤ãã£ãã§ãã
ãµã¼ãå ¨å°
puma
pumaã®ã¡ã¢ãªä»¥å¤ã®ã¡ããªã¯ã¹ãå¾åãããªãã®ã¯ãDatadogã®Puma Integrationã®è¨å®ãå ¥ããã®ãå¾åãªããã
MySQL
å ·ä½çã«ãã£ããã¨
CloudFormationããèµ·åããç´å¾ã®ã¤ã³ã¹ã¿ã³ã¹ã«ãã³ããã¼ã«ã¼ãå®è¡ï¼ã¹ã³ã¢ï¼4148ï¼
ãã¤ãã®ã¹ãããããã³ãã¼ãã¦åç §å®è£ ãGoããRubyã«å¤æ´ï¼ã¹ã³ã¢: 3781ï¼
ãã®æç¹ã§Ruby 3.3.0-devã«ãã¦ã¾ãã
Sentryã¨ddtraceï¼Datadogã®APMï¼ãæå¹åï¼ã¹ã³ã¢ï¼3497ï¼
ããã§ããããã¹ã¿ã¼ãå°ç¹
rubocop-isuconå°å ¥ï¼ã¹ã³ã¢ï¼3389ï¼
ãã¤ããªããã®æç¹ã§N+1ãã©ãããããããindexãè²¼ãç®æãè¦ã¤ãã¦ããã®ã§ãããä»ã¾ã§ã¨ã³ã¼ãã®æ¸ãæ¹ãå¾®å¦ã«éãããã§ASTã®æ§æãå¤ãã£ã¦ Isucon/Mysql2é¨ç½²ã®cop ãå ¨ãåããªãã£ãã®ãã·ã§ãã¯ã ã£ãããã
GET /api/user/:username/icon : DBã«ããç»åãéããï¼ã¹ã³ã¢ï¼3827ï¼
Datadogãè¦ãã GET /api/user/:username/icon
ãæããã«ããã«ããã¯ã«ãªã£ã¦ãã®ã§ããã¤ã®æ¹åã«çæã
ã¨ã³ããã¤ã³ããé¸ãã§Durationã®éé ãã¦ããã«ããã¯ãçºè¦ã
å°ãã¿ã§ãã https://github.com/sue445/isucon13-20231125/blob/main/ruby/config/ddtrace_init.rb#L55-L65 ã®ãããªã¢ã³ãã¼ãããããã¦ã¦SQLã®çã¯ã¨ãªï¼ãã¬ã¼ã¹ãã«ãã® ?
ãå
¥ã£ã¦ãªããã¤ï¼ãDatadogã«éä¿¡ãã¦explainåãããããã¦ã¾ããï¼ã¦ã¼ã¶ãå
¥åãããã¹ã¯ã¼ããDatadogã«å
¨é¨çã§éä¿¡ãããã®ã§æ¬çªã¢ããªã«ã¯çµ¶å¯¾ã«ãããããã¡ãªãããï¼
ã½ã¼ã¹è¦ããDBã«ç»åãä¿åããã¦ãã®ã§nginxã§è¿ããã¨ããã®ã§ããããã§1æé以ä¸æããã£ãã¨æãã¾ãã
ChatGPTã«èããªãããã£ã¦ãããæãã®nginxã®è¨å®ãæ¸ããã«æçµçã«ãã¼ã«ã«ã«ä¿åããç»åãsinatraã§è¿ãããã«ãã¾ããã
æçµçã«ãããªæãã§ããã«ããã¯æ¹åããã®ã確èªã
ããã§ãã¾ãæªããªãã®ã§1æéããããã«æ©ãã¨ãã諦ããã¹ãã ã£ãããããï¼1人ãã¼ã ã ã¨ããã£ãæã«ç¡éã«æéã溶ããï¼
fill_user_responseã§DBã®ç»åã使ããªãããã«ããï¼ã¹ã³ã¢ï¼4518ï¼
æå¾ã®æ¹ã§æ°ã¥ãããã©ç»åãä¿åããåã«è¨ç®ããhashãDBã«å ¥ããæ¹ãããã£ãã
2å°ç®ã®ãµã¼ããDBå°ç¨ã¨ãã¦æå ¥ï¼ã¹ã³ã¢ï¼6893ï¼
ãããå¾®å¦ã«ããã£ããã¤ã
ãããã¤æã«1å°ç®ã®ãµã¼ãã®MySQLãæ¢ãã¦2å°ç®ã®ãµã¼ãã®ã¿MySQLãèµ·åãã¦ãã®ã«ããããã¤å¾ã«ãªãã1å°ç®ã®ãµã¼ããæ¢ããã¯ãã®MySQLã復活ãã¦ãã£ã¡ãããåãããã«ããã£ã¦ã¾ããã
æçµçã«ã¯serviceãã¡ã¤ã«ã®Afterã¨Requiresãåå ã¨ããã£ã¦æ¶ãããã§ããããããããPowerDNSã使ã£ã¦ãMySQLã«ãå½±é¿ãã¦å¾©æ´»ããã¾ãã
MySQLã®ã¹ãã¼ãã°ãç¡å¹åï¼ã¹ã³ã¢ï¼7028ï¼
ã©ããè¦ãªãã®ã§ç¡å¹åãã
index追å ç¥ï¼ã¹ã³ã¢ï¼7132ï¼
POST /api/initialize
ã§ãã£ã¦ãTRUNCATE TABLEã ã¨indexãæ¶ããªãã¦ããã¨ãã£ã¦MySQLã 㨠ADD INDEX IF NOT EXISTS
ã®ãããªåªçæ§ã®ããDDLãåãããªãã£ãã®ã§initializeã§å®è¡ãããsqlãã¡ã¤ã«ã«å
¥ããã®ã諦ãã¦æåã§æå
¥ãããã¨ã«ãã¾ãããï¼gitã®å±¥æ´ã¨ãã¦ã¯æ®ãããã®ã§ãããããã¡ã¤ã«ã ãcommitï¼
livecomment_modelãnilã£ã¦NoMethodErrorã«ãªã£ãã®ã§ä¿®æ£
index追å ä¸ã«ããããã¨ã©ã¼ã«ééããã®ã§ä¿®æ£ãããããæsentry使ã£ã¦ãã¨æ¤åºã§ãã¦ä¾¿å©ã£ãããï¼ https://sentry.io ã®queueãè©°ã¾ã£ã¦ããããåãããªããã©æåã®æ¹ã¯å ¨ç¶ã¨ã©ã¼ãéç¥ãããªãã¦ã¤ããã£ããã©ï¼
3å°ç®æå ¥ï¼ã¹ã³ã¢ï¼7228ï¼
appå°ç¨ã¨ãã¦3å°ç®ãæå ¥ãã¦è² è·åæ£ãããã¨æã£ããã§ãããappããã¼ã«ã«ã®PowerDNSã«ä¾åãã¦ã¦ãã®PowerDNSãå¥ãµã¼ãã«åããã®ãæãããããã ã£ãã®ã§å®éã®è² è·åæ£ã¯å¾åãã«ãããã¨ã«ã
17:21é ã«åèµ·å試é¨
appã1å°ã§åããåæã«ããï¼ã¹ã³ã¢ï¼6949ï¼
ãã®æç¹ã§æ®ãæé1æéãã£ã¦ãã®ã§å±éºãªå¤æ´ã¯ããªãããã«ãã¾ãã
æå¾ã«Datadogã¨ã諸ã ç¡å¹åï¼ã¹ã³ã¢ï¼10663ï¼
æçµã¹ã³ã¢
10,663ãsue445.members.count==1ã(åèµ·åå¾ã¹ã³ã¢0)
ããããã¸ããã
競ææéä¸ã«åèµ·å試é¨ãã¦åé¡ãªãã£ãã®ã«ã追試ã®åèµ·å試é¨ã§ã¹ã³ã¢0ã«ãªãã¨ã¯æããªãã£ãã
æ¥å¹´ã«åãã¦
- ãã£ã¨ç´ æ¯ããã¦ç·´åº¦ãä¸ãã
- https://github.com/sue445/rubocop-isucon ã®ä¿®æ£