ãã®èšäºã¯ ã¢ããã³ãã«ã¬ã³ããŒ2023 3æ¥ç®ã®èšäºã§ãã
ããã¯ãªã«
ãµãŒã¯ã«ã®ããªã§ISUCONã«è»œãæ°æã¡ã§åå ããçµææ®éã«ããè² ããã人 (ãã¡) ã®è©±ã§ãã@cp20 èŠç¹ã§ãéãããŸãã
ISUCON13ã«ã¯ @chebrinko ãã @iChemy ãããšäžç·ã«ããŒã ãåå·ã©ãŒã¡ã³ããšããŠåå ããŠããŸãããããŒã å šå¡ãååºå Žã§ãçµæã¯7228ç¹ã§338äœã§ãããæ£ã®ã¹ã³ã¢ãåºããããŒã ã®äžã§ã¯ããªãäžã®æ¹ã®é äœãªã®ã§æšæãšãã£ãŠãå·®ãæ¯ããªãæ°ãããŸãã#æ®å¿µäŒäŒå Žã§ã®çºèšæš©ããã¡ãããããŸãã
ISUCON #ãšã¯
ISUCON ãšã¯ãikanji Speed Up Contestãã®ç¥ã§ãISUCONãšã¯LINEã€ããŒæ ªåŒäŒç€Ÿãéå¶çªå£ãšãªã£ãŠéå¬ããŠããããé¡ãšãªãWebãµãŒãã¹ã決ããããã¬ã®ã¥ã¬ãŒã·ã§ã³ã®äžã§éçãŸã§é«éåãå³ããã¥ãŒãã³ã°ããã«ã§ããã ããã§ã (å ¬åŒHPããåŒçš)
ããã ãã ãšãªãã ããããšãªããšæãã®ã§ããŠãºãã¡ãã (Custom Instructionã§æ¹é ããGPT-4) ã«èããŠã¿ãŸããã
å®éISUCONã¯ããªã人æ°ã§ãä»å¹ŽãçŸçãªåå æ äºããç¹°ãåºããããŸããã第äžæ ã¯éå§1åã¡ããã§åãŸã£ãã¿ããã§ãããæãã
ããšè³éããªããªã豪è¯ã§ã1äœã«ãªããš100äžåãããã¡ãããŸãã1人ã§åã€ãšæ¶é€ãå€ãã¡ãããŸããã
åå èš
ãããŸãç·Žç¿ã§ããŠãªãã£ããã§ããã倧äŒåœæ¥ã¯ç¡æ æ²ã«ããã£ãŠããŸããã
åœæ¥ã¯èª°ãå¯åããããšãªããç¡äº10æã«ç«¶æãå§ããŸãããæã£ãããã¬ãã£ãšå§ãŸããŸããã
æåã®æ¹ã¯ã㯠(@cp20) ãè¯ãæãã«èšæž¬ç°å¢ãšãããã€ç°å¢ãæŽããŠããéã«ã@chebrinko ãããš @iChemy ããã«ããããã¢ããªã®ã³ãŒããšããã¥ã¢ã«ãèªãã§ããããŸãããæã£ãããç°å¢æŽããã®ã«æããã£ã¡ãã£ãŠããŸãšãã«ç°å¢ãæŽã£ãã®ã¯12æéããããã§ããããããæ¹åãå°ããã€å ¥ããŠãããŸããã
æåããã¢ã€ã³ã³ã®ãªã¯ãšã¹ããããã«ããã¯ã«ãªã£ãŠãããšã¯ããã£ãŠãããã§ãããããã·ã¥å€ããã£ãã·ã¥ããŠãæ©ããªããªãããç»åãã®ãã®ã®ãã£ãã·ã¥ã¯å®è£ ã«å€±æãããã§æåŸãŸã§ããã«ããã¯ã«ãªãç¶ããŸãããISUCONãžãããã§ããIf-None-Matchã®ä»æ§ãæ®éã®ãã©ãŠã¶ãšéãããã¿ãããªè©±ã話é¡ã§ããããã®ããšã«ç«¶æäžã«æ°ä»ããªãã£ãã®ã§ããã¶ã304ãè¿ãããšãã倱æããŠããŸããã
ãã N+1ã®æ¹åã¯æ¯èŒçããŸãã§ããŠãChatGPTãšGitHub CopilotãããŸãé§äœ¿ããªããå§åçã«éãããããšãã§ããŸãããstatisticsç³»ã®ãšã³ããã€ã³ãã¯çéã«ãªããŸãããã¹ã³ã¢ã¯äžãããªããã©ã
ããšfill~~~ç³»ã®é¢æ°ãé ããšããããšãåãã£ãŠãããã§ãããäžæãçŽãæ¹æ³ããããããããããããã«ããã¯ã§ããç¶ããŸãããISUCONãžãããã§ãã
è€æ°å°æ§æã«ããããšã§è² è·ãåæ£ããã®ãäžè¬çã ãšæããŸãããè€æ°å°æ§æã«ããŠãè¬ã«ã¹ã³ã¢ãäžãããªãã£ãã®ã§çµå±1å°ã§ãããŸããããªãã§ã§ãããã
å šäœçã«ããçšåºŠéããªã£ãã¯ããªãã§ãããã¹ã³ã¢ãå šç¶äŒžã³ãªãã£ãã®ã¯ãªãã§ã§ããããïŒãã¯ã«ã¯ããããŸããã
åçç¹
ISUCON13 åé¡ã®è§£èª¬ãšè¬è© ã«ããªãå šãŠããŸãšãŸã£ãŠããŸãã
åå
èšæž¬ç°å¢ãæŽãããããªããžããªãããããã€ããæµããæŽãããããæµãã§çµæ§è©°ãŸã£ã¡ãã£ãã®ã¯ãã£ãšæ¹åã§ãããªããšæããŸããããã¯çŽç²ã«ç·Žç¿äžè¶³ã§ãããååã¯äžçªç·Žç¿ã®å·®ãåºããšãããããã®ã§ããã£ãšé 匵ãããã§ããã
ã€ã³ããã¯ã¹
ã€ã³ããã¯ã¹ã¯è²ŒããŸããããå¿ èŠãªãšããã«é©å®è²Œã£ãŠããã¿ãããªæãã§ãã£ãŠããã§ããããã£ãšè²ŒããŸãã£ãŠãããããã§ãã解説ã«ããã°ã€ã³ããã¯ã¹è²Œãã ãã§10000ç¹ãããè¡ããããã§ãããã¯ãã¡ã®ããŒã ã®æçµã¹ã³ã¢è¶ ããŠããã ãã©ããã
ã¢ã€ã³ã³ã®ãã€
If-None-Matchã«ã€ããŠã¯ããã£ããåããŠããã©ããã確èªããŸãããã£ãŠããæãã§ãããããã£ãã·ã¥ãå ¥ããããã£ãã·ã¥ããããããŠãã確èªããªãïœãïŒ
fill~~~é¢æ°
é 匵ã£ãŠæ¹åããŸãããããããã解決çãããã¿ããã§ãããæ®éã«ç·Žç¿ã足ããŠãªãã£ãã§ãã
DNS察å¿
ãããDNS氎責ãæ»æã£ãŠãªãã ããïŒæŸçœ®ã§è¯ãããã¿ãããªæ°æã¡ã§ãããã§ãããããçµæ§éèŠã ã£ãã¿ããã§ããã¯ãšãªãé ãã£ãã®ã§é©åœã«ã€ã³ããã¯ã¹è²Œã£ãŠããã§ããããããããšæ°Žè²¬ãã®ã¬ãã«ãäžãã£ãŠãããŸè¯ããªããšãã話ããããããã§ãã
äžæ£ãªãªã¯ãšã¹ãã¯æ»æãªã®ã§ç¡èŠããŠããããããã§ãããããããçºæ³ã«ãªããŸããã§ãããISUCONã£ãŠåã«éãããã ããããªããŠããããæŠè¡ãæ±ãããããã ãªããããšããã
è€æ°å°æ§æ
ãããç·Žç¿ã足ããªããšãããªæ°ãããŸããããããäœãéãã®ãããã£ãŠããªãããäœãæ¹åãããããã®ãããããªãç¶æ ã
ãã³ãããŒã«ãŒã®æ°æã¡
ä»åã®åé¡ã¯ããŠãŒã¶ãŒã®æãéã®éé¡ã®åèšããã¹ã³ã¢ã«ãªãããããäœãããã°ãŠãŒã¶ãŒãæãéãããŠãããã®ãã¯ãããŸãæžããŠãããŠãŸãããå šäœçã«é ããšãããéãããŠãã£ããã§ããããããŸãã¹ã³ã¢ãäžãããªããŠããã³ãããŒã«ãŒåã¯äœãæãã§ãããã ãã...ïŒã¿ãããªæ°æã¡ã«ãªã£ãŠãŸãããã©ãããããã³ãããŒã«ãŒåã«å¯ãæ·»ããã®ãããã£ãŠããŸããã
âã®èšäºã®ããŒã«ãšãããã³ãããŒã«ãŒã®æ°æã¡ãç解ããã®ã«åœ¹ç«ã€ã®ããªïŒãšããæ°ãããŠããŸãã
è¯ãã£ãç¹
åå ã§ãã
åå æ ãç¡äºåã㊠(å®ã¯11çª) åœæ¥ãå¯åããã«åå ã§ããã®ã¯åããšæã£ãŠããŸãã
N+1ã®æ¹å
statisticsç³»ã®ãšã³ããã€ã³ãã1åã®ãªã¯ãšã¹ãã§äœç§ãšãããã¬ãã«ã§æéãããã£ãŠãã®ãããµã¯ããš10ïœ100åãããé«éåã§ããã®ã¯è¯ãã£ãæ°ãããŸããç·Žç¿ã®ææ(?)
ã³ã³ããªã¯ããèµ·ããªãã£ã
ä»åã¯å šå¡ååå ãšããããšã§ãã¬ãããªåœ¹å²åæ ã¯ãããåã ãæ¹åãããŠãã³ããåããŠããæãã ã£ããããŒãžã¿ãããªæŠç¥ãåã£ãŠãããã§ããããã®ã·ã¹ãã ã¯å²ãšããŸãåã£ãŠããæ°ãããŸããåé¡ã¯åã ã®èœåããããªã«é«ããªããæ ã«ãããŸãæ¹åãå ¥ããªãããšã§ããã
ææ³
@cp20
å»å¹ŽãããããISUCONã®ååšã¯ç¥ã£ãŠãããã§ãããå ¬åŒãµã€ãã®æ§é ãè¯ãããããªããŠã©ããã倧äŒãªãã ...ïŒãšããæ°æã¡ã§ãããtraPã«å ¥ã£ãŠISUCONã®è©±ãè²ããªäººãããŠãã®ãè³ã«ããŠãããããISUCONãã©ãããæãã®å€§äŒãªã®ããããããŸããã(ã¡ãªã¿ã«traPã«å ¥ãåã¯traPãISUCON匷ããšããã®ã¯ç¥ããŸããã§ãã)
å®éåå ããŠã¿ãŠããã£ãéšåãå€ãæ°ãããŸããè¬ç¿äŒåããããèªåã§ç·Žç¿ããŠã¿ãŠçµæ§ç¥ã£ãŠãæ°ã«ã¯ãªã£ãŠããã§ãããå®é8æéã¶ã£ç¶ãã§æ¬çªããã£ãŠã¿ããšèŠããŠãããã®ããããŸãããæã£ãããèšæž¬ç°å¢çšæããã®å€§å€ãšãã
ããšã¯å ¬åŒã®è§£èª¬ãšãåå è ã®ããã°ãšãã§è§£æ³ãèŠãŠããšããããªæ¹åãã§ããã®ãïœãµããµãã¿ãããªæ°æã¡ã«ãªããŸãããŸã åå¿è ãªã®ã§å ¬åŒã®è§£èª¬ã®å 容ãããŸã ãŸã ãšããæããªãã§ããã
ããããã°ãã®ããã°ã®ã¿ã€ãã«ã¯ãð ISUCON åå¿è æŠããïŒ æ€çŽ¢ãã§ããããæŠãããæŠããªããã§ãããšæŠããªãããšã¯ãªããããã ãšæããŸããããããæåã¯åæã¹ã³ã¢ãããé«ãã¹ã³ã¢ãåºãã°ãšã·ïŒãããã®æ°æã¡ã§åå ããŠããã¶ãåçç¹ãç¡éã«çãŸããã®ã§ããããã£ãã次ã«çãããã°å®ããããã®ããªããšããæ°æã¡ã§ãã
ãã¯ã¯æ¥å¹Žä»¥éãåå ããæ°ã§ã¯ããã®ã§ããã£ãšç²Ÿé²ããŠããé äœãåºããããã«é 匵ããããªãšæã£ãŠããŸãã
@chebrinko
åŠçç掻æåã§æåŸã®ISUCONã§ããã競ææéã®8æéã¯ãã£ãšããéã§ããã
ç§å人ãšããŠãç·Žç¿ãããŸãããã«æ¬çªã«æãã§ããŸããããŒã ã«ããŸãè²¢ç®ã§ããåçç¹ãå€ãçµæã«ãªããŸãããç·Žç¿ãããªããšæ¹åã¯é£ããã§ãã... æ¬çªã¯ãããŸãå¹æçã§ã¯ãªãã£ãã§ãããDBã«ã€ã³ããã¯ã¹ã貌ã£ãŠã¿ãããµãŒããŒãåé¢ããŠã¿ããããŸãããä»åŸã¯èšæž¬ããŒã«ãçšããŠæ¹åã§ããéšåããã¡ããšç¹å®ããDBã€ã³ããã¯ã¹ã®æŽ»çšãN+1ãç¡ãããããã£ãã·ã¥ãå©çšããŠã¿ãããšããåºæ¬çãªæ¹åãã§ããããã«ãªãããã§ãã
@cp20 ããã¯ãéå¶ãšã®ãããšãïŒç³ã蟌ã¿ãèªå·±çŽ¹ä»ã¹ã©ã€ãã®èšå ¥ãªã©)ãç·Žç¿æ¥çšã®èª¿æŽã ã£ããç·Žç¿ç°å¢ã®ã»ããã¢ãããªã©æ¬çªåå¿ èŠãªããšã¯äœããäœãŸã§ããŠãããŸãããåœæ¥ã®ååãããããã€ãèšæž¬ããŒã«ã®ç°å¢ã»ããã¢ãããšããäžçªå€§å€ãªéšåããã£ãŠãããŸãããããŒã ãªãŒããŒã«ã¯æè¬ã§ãã£ã±ãã§ãã(ããšãããŸãã®ã©ãŒã¡ã³ã®åçã綺éºã§ã³ã£ããããŸããã) @iChemyãããäžç·ã«åºãŠãããŠããããšãããããŸããã
@iChemy
ç§ãååå ã§ã®ISUCONã§ããïŒããŒã ã§äœåãéå»åã解ãæ©äŒã¯ãããŸããããã®ãšãããç¹æ°ã䌞ã³ã«ãããªãšããå°è±¡ãåããŠïŒãããæ¬çªãâŠãªã©ãšåæã«æã£ããããŠããŸããïŒ
ååã¯äžå¿ããã¥ã¢ã«æ åœã§ããããããšãã£ã掻èºã¯èŠãããªãã£ãããšããããŸããïŒåå¿è ã®ãã¡ã¯ã¿ããªã§èªã¿åãããã®ãè¯ãã®ããªãšããå°è±¡ã§ãïŒç«¶æãå§ãŸã£ãŠãã°ããã¯é©åœã«ã€ã³ããã¯ã¹ã貌ã£ããã³ãŒããçºããŠãããããŸããïŒngã¯ãŒãã®åŠçåšãã§é£ããã¯ãšãªããã£ãŠäœãããŠããã®ã調ã¹ãŠããç¬éããããŸããïŒæ¬¡åãŸã§ã«SQLã¯ãã£ããé ã«å©ã蟌ãã§ãããæ¹ãè¯ãããã§ãïŒ
éäžãããšããããèªåã§ãæ¹åã§ããããªãšãããèŠã€ããããšããŠreserveLivestreamHandlerã§ãã«ã¯ã€ã³ãµãŒãã«ããŠã¿ããnginxã®èšå®ãé©åœã«ããã£ããããŸãããæ ¹æ ã®ããæ¹åã§ã¯ãªãã¹ã³ã¢ã¯äŒžã³ãªãã£ã(nginxã®èšå®ã«é¢ããŠã¯äžãã£ã)ã®ãèŠãŠãæšæž¬ãããªãèšæž¬ãããã®ãæšæž¬ãããªããçæããç¬éããããŸããïŒ
ãã£ãšã¡ãããšå¯ŸçããŠããã°è¯ãã£ããª(?å ·äœçã«äœãããã°è¯ããã¯ããããŸããã)ãšããå°è±¡ã§ãïŒãŸããã€ã(æ¥å¹Žãåæ¥å¹ŽãããããŸããã)ããå°ãå¥éã§ããããã«ãªã£ãŠåææŠãããã§ãïŒ
ææ¥ã¯ @s9 ãããš @botoku_izm ããã®èšäºã§ãïŒã楜ãã¿ã«ïŒ
ããŸã
ããŒã åããåå·ã©ãŒã¡ã³ããªã®ã§ãæã¡äžãã§åå·ã«ã©ãŒã¡ã³ãé£ã¹ã«è¡ããŸããããã¡ãçŸå³ããã£ãã§ãã
(ã¡ãªã¿ã«ããã¯ã€ã麺)