é ããµã€ããæªãããšã¯èª°ããç¥ã£ãŠããŸãã ãµã€ãã®é床ãäœäžãããããæ¥åžžã®ã¿ã¹ã¯ã解決ããéã«æ·±å»ãªåé¡ãçºçããŸãã æã ããã¯åã«è¿·æã§ãã å€ãã®å Žåããµã€ãã®ãã¬ãŒãã³ã°ã¯æ éãã€ãŸããµãŒãã¹æåŠã§ããã人ã ã¯ããŠã³ããŒããåŸ ã£ãŠç«ã¡å»ããŸããã ããã¯ãããšãã°ãããŒãžã¬ã³ããªã³ã°ã®éå§ãã¯ãªãã¯åŸ8ã10ç§ã§å§ãŸãå Žåãªã©ããµã€ãã®æ ¹æ¬çãªé»å®³ã®å Žåã«é¢é£ããŸãã
ãµã€ããæ¯èŒçè¯å¥œãªç¶æ³ïŒæç·ã€ã³ã¿ãŒããããšææ°ã®ã³ã³ãã¥ãŒã¿ãŒã§é«éã«ããŒãããå ŽåïŒã§ããããŠã³ããŒãã®é 延ã¯èŠèŽè ã®æ倱ãšã³ã³ããŒãžã§ã³ã®æžå°ã«ã€ãªããå¯èœæ§ããããŸãã ããšãã°ãAmazonã¯100ããªç§ïŒ0.1ç§ïŒã®é 延ããšã«å£²äžã1ïŒ æžå°ããããšãå€æããå®éšãå®æœããŸããã
ããããä»æ¥ã®ãªã³ã©ã€ã³èŠèŽè ã®åæ°ä»¥äžãã¢ãã€ã«ããã€ã¹ã䜿çšããŠãµã€ãã«ã¢ã¯ã»ã¹ããŠããŸãã ãã®ãããã¢ã¯ã»ã¹ãšããã»ããµã«äœéã®ãã£ãã«ã䜿çšããŠãµã€ããããŒãã§ããŸãã
ãµã€ãã®é床ã®åé¡ã®éèŠæ§ã®3çªç®ã®çç±ã¯æè¡çã§ãã ååãšããŠãäœéãªãµã€ãã§ã¯ãã¹ãã£ã³ã°ãªãœãŒã¹ã®æ¶è²»éãå¢å ããè¿œå ã³ã¹ããçºçããŸãã ãµãŒããŒåŽã®ãã¬ãŒãã¯ããµã€ãã®ããŒã¯è² è·ã«ã·ãŒã ã¬ã¹ã«èããèœåãäœäžãããŸãã
ãããã£ãŠããµã€ãã®é床ã¯ãæè¡çããã³çµæžçãªèŠ³ç¹ãã察åŠããå¿ èŠããããŸãã ãã®èšäºã§ã¯ããŠã§ããµã€ãã®é«éåã®æè¡çãªåŽé¢ã«éäžããŸãã
ãµã€ãã®é床ïŒäž»èŠãªã³ã³ããŒãã³ã
ãµã€ãã®é床ã¯ãã¯ã©ã€ã¢ã³ããšãµãŒããŒã®2ã€ã®åŽé¢ã«åœ±é¿ããŸãã çŸåšããããã®åããŒãã¯æçµçµæãšåçã§ãã ããããããããç¬èªã®ç¹åŸŽããããŸãã
ãµã€ãã®ããŒãžèªã¿èŸŒã¿æéã®åœ¢æå ãç解ããããã«ããã®ããã»ã¹ã段éçã«åæããŸãã ãã®çµæããµãŒããŒãšã¯ã©ã€ã¢ã³ãã®æé©åã®æ©èœãã©ãã«ããããç解ã§ããŸãã
ãµã€ããèªã¿èŸŒãå®å šãªããã»ã¹ïŒæåã®èšªåïŒã¯æ¬¡ã®ãšããã§ãã
- ãµã€ãåã«ããDNSã¯ãšãªã
- IPãä»ãããµãŒããŒãžã®æ¥ç¶ïŒTCPæ¥ç¶ïŒã
- HTTPSïŒTLSæ¥ç¶ïŒã䜿çšããŠå®å šãªæ¥ç¶ã確ç«ããŸãã
- URLã§HTMLããŒãžãèŠæ±ãããµãŒããŒãåŸ ã¡ãŸãã ïŒHTTPãªã¯ãšã¹ãïŒ
- HTMLã®èªã¿èŸŒã¿ã
- ãã©ãŠã¶åŽã§HTMLããã¥ã¡ã³ãã解æããããã¥ã¡ã³ããªãœãŒã¹ã«ãªã¯ãšã¹ãã®ãã¥ãŒãäœæããŸãã
- CSSã¹ã¿ã€ã«ã®èªã¿èŸŒã¿ãšè§£æã
- JSã³ãŒããããŠã³ããŒãããŠå®è¡ããŸãã
- ããŒãžã¬ã³ããªã³ã°ã®éå§ãJSã³ãŒãã®å®è¡ã
- Webãã©ã³ããããŠã³ããŒãããŸãã
- ç»åããã®ä»ã®ã¢ã€ãã ãããŠã³ããŒãããŸãã
- ããŒãžã®ã¬ã³ããªã³ã°ã®çµäºãä¿çäžã®JSã³ãŒãã®å®è¡ã
ãã®ããã»ã¹ã§ã¯ãããã€ãã®äœçœ®ã¯äžŠè¡ããŠçºçããããã€ãã¯å Žæãå€ãããããããŸããããæ¬è³ªã¯åããŸãŸã§ãã
ãµãŒããŒã®æé©åã§ã¯ã第1段éãã第4段éãŸã§ãæ±ããŸãã æé 5ã12ã¯ã¯ã©ã€ã¢ã³ãã®æé©åã§ãã ãããã®å段éã§è²»ããããæéã¯ãµã€ãããšã«ç°ãªãããããµã€ãã®ã¡ããªãã¯ãååŸããåé¡ã®äž»ãªåå ãç¹å®ããå¿ èŠããããŸãã ããã§ããããã®ã¡ããªãã¯ãååŸããŠè§£éããæ¹æ³ã®åé¡ã«ç§»ããŸãã
ãµã€ãé床枬å®
äž»ãªè³ªåïŒäœã枬å®ããå¿ èŠããããŸããïŒ ãµã€ãã®é床ã«é¢ããå€ãã®ææšããããŸãããããã»ã©å€ãã¯ãããŸããã
ãŸããæåã®ãã€ããŸã§ã®æéïŒTTFB-æåã®ãã€ããŸã§ã®æéïŒã¯ãããŠã³ããŒãããã»ã¹ã®éå§ãããµãŒããŒããã®ããŒã¿ã®æåã®éšåã®åä¿¡ãŸã§ã®æéã§ãã ããã¯ããµãŒããŒæé©åã®åºæ¬çãªã¡ããªãã¯ã§ãã
第äºã«ãããã¯ããŒãžã®ã¬ã³ããªã³ã°ã®éå§ã§ãïŒã¬ã³ããªã³ã°ã®éå§ãæåã®ãã€ã³ãïŒã ã¡ããªãã¯ã¯ãããŒãžãæç»ãéå§ãããšãã«ãã©ãŠã¶ãŒã®ãçœãç»é¢ãæéãçµäºãããŸã§ã®æéã瀺ããŸãã
第äžã«ãããŒãžã®äž»èŠãªèŠçŽ ã®ããŒãïŒããŒãæéïŒã§ãã ããã«ã¯ãããŒãžãæäœããããã®ãã¹ãŠã®ãªãœãŒã¹ã®èªã¿èŸŒã¿ãšè§£éãå«ãŸããŸãããã®ããŒã¯ã®åŸãããŒãžèªã¿èŸŒã¿ã€ã³ãžã±ãŒã¿ã®å転ãåæ¢ããŸãã
第4ã«ãããã¯ãã«ããŒãžããŒãã§ãããã©ãŠã¶ã®ã¡ã€ã³ã¢ã¯ãã£ããã£ãçµäºãããŸã§ã®æéã§ãã¡ã€ã³ããã³ä¿çäžã®ãã¹ãŠã®ãªãœãŒã¹ãããŒããããŸãã
ãããã®ã³ã¢ã¡ããªãã¯ã¯æ°ç§ã§æž¬å®ãããŸãã 3çªç®ãš4çªç®ã®ã¡ããªãã¯ã®ãã©ãã£ãã¯éãèŠç©ããããšã圹ç«ã¡ãŸãã æ¥ç¶é床ãèµ·åæéã«äžãã圱é¿ãè©äŸ¡ããã«ã¯ããã©ãã£ãã¯ãç¥ãå¿ èŠããããŸãã
ããã§ãé床ããã¹ãããæ¹æ³ãç解ããå¿ èŠããããŸãã ãµã€ãã®è² è·é床ã®ã¡ããªãã¯ãè©äŸ¡ããããã®å€ãã®ãµãŒãã¹ãšããŒã«ãããããããããã¿ã¹ã¯ã«é©ããŠããŸãã
æã匷åãªããŒã«ã®1ã€ã¯ããã©ãŠã¶ãŒããã·ã¥ããŒãã§ãã Chromeã§æãéçºãããããã«æ©èœã [ãããã¯ãŒã¯]ã¿ãã§ã¯ãHTMLããã¥ã¡ã³ãèªäœãå«ããã¹ãŠã®èŠçŽ ã®èªã¿èŸŒã¿æéã«é¢ããã¡ããªãã¯ãååŸã§ããŸãã èŠçŽ ã«ã«ãŒãœã«ãåããããšããªãœãŒã¹ãååŸããå段éã§è²»ããããæéã確èªã§ããŸãã ããŒãžã®èªã¿èŸŒã¿ããã»ã¹ã®å šäœåãè©äŸ¡ããã«ã¯ãããã©ãŒãã³ã¹ã¿ãã䜿çšããŸãããã®ã¿ãã§ã¯ãç»åã®ãã³ãŒãæãŸã§ã®è©³çŽ°ã衚瀺ãããŸãã
詳现ãªãã§ãµã€ãã®é床ãè©äŸ¡ããå¿ èŠãããå Žåããµã€ãç£æ»ïŒ[ç£æ»]ã¿ãïŒãéå§ãããšäŸ¿å©ã§ããLighthouseãã©ã°ã€ã³ã䜿çšããŠå®è¡ãããŸãã ã¬ããŒãã§ã¯ãã¢ãã€ã«ããã€ã¹ã®é床ã®æšå®å€ïŒäž¡æ¹ãšããã€ã³ãã§ç©åãããŠãããããã¡ã€ã³ã¡ããªãã¯ã¹ïŒãšä»ã®ããã€ãã®ã¬ããŒããååŸããŸãã
WebãµãŒãã¹ã®äžã§ã WebPagetestã¯ãããã§ãã·ã§ãã«ãªæšæºã«ãªããŸããã ãã®ãµãŒãã¹ã¯ãæå®ãããçš®é¡ã®æ¥ç¶ã§å®éã®ãã©ãŠã¶ã«ãµã€ããããŒããããã¹ãŠã®ã¹ããŒãžãšã¡ããªãã¯ã«é¢ãã詳现ãªã¬ããŒããçæããŸãã
ã¯ã©ã€ã¢ã³ãã®æé©åããã°ããè©äŸ¡ããã«ã¯ãGoogle PageSpeed InsightsãµãŒãã¹ã䜿çšã§ããŸãããããŠã³ããŒãæéã«é¢ããæãéèŠãªã¡ããªãã¯ã®ã»ãšãã©ãå«ãŸããŠããªãããšã«æ³šæããå¿ èŠããããŸãã æåŸã«ãå®éã®ãŠãŒã¶ãŒã®ãµã€ãã®èªã¿èŸŒã¿æéãåæãããšåœ¹ç«ã¡ãŸãã Webåæã·ã¹ãã Yandex.Metricaããã³Google Analyticsã«ã¯ããã®ããã®ç¹å¥ãªã¬ããŒãããããŸãã
ãµã€ãã®èªã¿èŸŒã¿æéã®ã¬ã€ãã©ã€ã³ã¯æ¬¡ã®ãšããã§ããã¬ã³ããªã³ã°ã®éå§ã¯çŽ1ç§ãããŒãžã®èªã¿èŸŒã¿ã¯3ã5ç§ä»¥å ã§ãã ãã®ãã¬ãŒã ã¯ãŒã¯ã§ã¯ããŠãŒã¶ãŒã¯ãµã€ãã®é床ã«ã€ããŠæå¥ãèšãããšã¯ãªããèªã¿èŸŒã¿æéã¯ãµã€ãã®å¹æãå¶éããŸããã ãããã®æ°å€ã¯ãã¢ãã€ã«æ¥ç¶ãå€ãããã€ã¹ã®å°é£ãªç¶æ³ã§ãã£ãŠããå®éã®ãŠãŒã¶ãŒã§æ£ç¢ºã«éæããå¿ èŠããããŸãã
ãµãŒããŒã®æé©å
Webãµã€ãã®é«éåèªäœã«é²ã¿ãŸãããã ãµãŒããŒåŽã®æé©åã¯ããµã€ãéçºè ã«ãšã£ãŠæãç解å¯èœã§æçœãªæ段ã§ãã ãŸãããµãŒããŒéšåã¯ã·ã¹ãã 管çè ã«ãã£ãŠç°¡åã«ç£èŠããã³å¶åŸ¡ãããŸãã 第äºã«ããµãŒããŒã®å¿çæéã«é倧ãªåé¡ããããããæ¥ç¶é床ãããã€ã¹ã«é¢ä¿ãªãããã¹ãŠã®äººãã¹ããŒããŠã³ãèªèã§ããŸãã
ãµãŒããŒåŽã®ãã¬ãŒãã³ã°ã®çç±ã¯éåžžã«å€æ§ã§ãããšããäºå®ã«ãããããããèŠãªããã°ãªããªãå žåçãªå ŽæããããŸãã
ãã¹ãã£ã³ã°ïŒãµãŒããŒãªãœãŒã¹ïŒ
ããã¯ãå°ããªãµã€ãã§ãã¬ãŒãããããäžçªã®çç±ã§ãã ãµã€ãã®çŸåšã®è² è·ã«ã€ããŠã¯ããã¹ããªãœãŒã¹ãååã§ã¯ãããŸããïŒéåžžãããã¯CPUãšãã£ã¹ã¯ã·ã¹ãã ã®é床ã§ãïŒã ãããã®ãªãœãŒã¹ãããã«å¢ããããšãã§ããå Žåã¯ãè©ŠããŠã¿ã䟡å€ããããŸãã å Žåã«ãã£ãŠã¯ãåé¡ã¯è§£æ±ºãããŸãã è¿œå ã®ãªãœãŒã¹ã®ã³ã¹ããæé©åäœæ¥ã®ã³ã¹ããããé«ããªã£ãå Žåã次ã®æ¹æ³ã«é²ãå¿ èŠããããŸãã
DBMSïŒããŒã¿ããŒã¹ãµãŒããŒïŒ
ããã§ãåé¡ã®åå ã§ããããã°ã©ã ã³ãŒãã®äœéåã解決ããããã«ããã§ã«é²ãã§ããŸãã å€ãã®å ŽåãWebã¢ããªã±ãŒã·ã§ã³ã¯ããŒã¿ããŒã¹ã®ã¯ãšãªã«è²»ããããŸãã Webã¢ããªã±ãŒã·ã§ã³ã®ã¿ã¹ã¯ã¯ããŒã¿ãåéããç¹å®ã®ãã³ãã¬ãŒãã«åŸã£ãŠå€æããããšã§ãããããããã¯è«ççã§ãã
ããŒã¿ããŒã¹ããã®å¿çãé ããšããåé¡ã®è§£æ±ºçã¯ãéåžžã2ã€ã®æ®µéã«åããããŸããDBMSã®èª¿æŽãšãã¯ãšãªãšããŒã¿ã¹ããŒã ã®æé©åã§ãã DBMSïŒããšãã°ãMySQLïŒã®ãã¥ãŒãã³ã°ã¯ããã¥ãŒãã³ã°ã以åã«è¡ãããŠããªãã£ãå Žåãæ°åå éããå¯èœæ§ããããŸãã 埮調æŽã«ããã10ããŒã»ã³ã以å ã®å¹æãåŸãããŸãã
ã¯ãšãªã®æé©åãšããŒã¿ã¹ããŒãã¯ãã¹ããŒããäžããããã®ææ¬çãªæ¹æ³ã§ãã ãã®æé©åã«ãããæ°æ¡ã®å éãåŸãããŸãã ãµã€ãã®ããã°ã©ã ã³ãŒãã«äŸµå ¥ããããšãªãããŒã¿ããŒã¹ã®æ§é ã®å€æŽãçºçããå¯èœæ§ãããå Žåãã¯ãšãªã®æé©åã«ã¯ãã®ãããªä»å ¥ãå¿ èŠã«ãªããŸãã
é ãã¯ãšãªãç¹å®ããã«ã¯ãããªãé·ãæéããŒã¿ããŒã¹ã®è² è·ã«é¢ããçµ±èšãåéããå¿ èŠããããŸãã 次ã«ããã°ã®åæãšæé©åã®åè£ã®èå¥ãå®è¡ãããŸãã
CMSãšããã°ã©ã ã³ãŒãã®åœ±é¿
ãµã€ãã®é床ã¯CMSïŒããšã³ãžã³ãïŒã®ã¿ã«äŸåãããšéåžžã«åºãä¿¡ããããŠããŸãã ãŠã§ããµã€ãã®ææè ã¯ãCMSãé«éãšäœéã«åå²ããããšããããšããããããŸãã å®éãããã¯å®å šã«çå®ã§ã¯ãããŸããã
ãã¡ããããµãŒããŒã®è² è·ã¯ã䜿çšãããCMSã«å«ãŸããã³ãŒãã«äŸåããŸãã ãã ããã»ãšãã©ã®äžè¬çãªã·ã¹ãã ã¯æ倧é床ã«æé©åããããšãããµã€ãã®é床ã«é¢ããèŽåœçãªåé¡ã¯ãã¹ãã§ã¯ãããŸããã
ãã ããã¡ã€ã³ã®CMSã³ãŒãã«å ããŠããµã€ãã«ã¯ããµã€ãã®éçºè ã«ããè¿œå ã®ã¢ãžã¥ãŒã«ïŒãã©ã°ã€ã³ïŒãæ¡åŒµæ©èœãããã³å€æŽãå«ãŸããŠããå ŽåããããŸãã ãããŠããã§ã«ãã®ã³ãŒãã¯ãµã€ãã®é床ã«æªåœ±é¿ãåãŒãå¯èœæ§ããããŸãã
ããã«ãã·ã¹ãã ãä»ã®ç®çã§äœ¿çšãããå Žåãé床ã®åé¡ãçºçããŸãã ããšãã°ãããã°ã·ã¹ãã ã䜿çšããŠã¹ãã¢ãäœæããŸãã ãŸãã¯ãå°èŠæš¡ãµã€ãçšã®ã·ã¹ãã ã䜿çšããŠããŒã¿ã«ãéçºããŸãã
ãã£ãã·ã³ã°
ãµãŒããŒã®é床ãåäžãããããã®æã匷åã§æ®éçãªæ段ã¯ãäŒçµ±çã«ãã£ãã·ã³ã°ã§ãã ããã§ã¯ãããããŒã®ãã£ãã·ã¥ã§ã¯ãªãããµãŒããŒã®ãã£ãã·ã¥ã«ã€ããŠèª¬æããŸãã çµæã®èšç®ïŒããŒãžã®ã¢ã»ã³ããªããããã¯ïŒã«å€§éã®ãªãœãŒã¹ãå¿ èŠãªå Žåã¯ãçµæããã£ãã·ã¥ã«å ¥ããŠå®æçã«æŽæ°ããŸãã ã¢ã€ãã¢ã¯åæã«ã·ã³ãã«ã§è€éã§ãããã£ãã·ã³ã°ã·ã¹ãã ã¯ããã°ã©ãã³ã°èšèªããµã€ã管çã·ã¹ãã ãWebãµãŒããŒã«çµã¿èŸŒãŸããŠããŸãã
éåžžãããŒãžãã£ãã·ã¥ã«ãããããŒãžã®ã¬ã³ããªã³ã°æéãæ°åããªç§ã«ççž®ã§ããŸãã åœç¶ããã®å ŽåããµãŒããŒã¯ç°¡åã«ããŒã¯ãã©ãã£ãã¯ãçµéšããŸãã 2ã€ã®åé¡ããããŸãããã¹ãŠããã£ãã·ã¥ã§ããããã§ã¯ãªãããã£ãã·ã¥ãæ£ããç¡å¹ã«ããïŒãªã»ããããïŒå¿ èŠããããŸãã åé¡ã解決ããå ŽåããµãŒããŒã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ã®å¹æçãªæ段ãšããŠãã£ãã·ã¥ãæšå¥šã§ããŸãã
TCPãTLSãHTTP / 2ã®æé©å
ãã®éšåã§ã¯ããµãŒããŒã®é«éåãå®çŸãã埮åŠãªãããã¯ãŒã¯æé©åãçµã¿åãããŸããã ããã§ã®å¹æã¯ãä»ã®æ¹æ³ã»ã©åºãã¯ãããŸãããããã¥ãŒãã³ã°ã«ãã£ãŠã®ã¿éæãããŸããã€ãŸããç¡æã§ãã
ä»æ¥ã®TCPã®èª¿æŽã¯ã10Gã®æ¥ç¶ãæã€å€§èŠæš¡ãªãããžã§ã¯ããšãµãŒããŒã«å¿ èŠã§ããèŠããŠããã¹ãäž»ãªããšã¯ããããã¯ãŒã¯ãµãã·ã¹ãã ãæ°ããLinuxã«ãŒãã«ã®ãªãªãŒã¹ã§å®æçã«æŽæ°ããããããæŽæ°ãã䟡å€ãããããšã§ãã é©åãªTLSæ§æïŒHTTPSïŒã䜿çšãããšãé«ã¬ãã«ã®ã»ãã¥ãªãã£ãååŸããå®å šãªæ¥ç¶ã®ç¢ºç«ã«ãããæéãæå°éã«æããããšãã§ããŸãã MozillaããªãªãŒã¹ããåªããæšå¥šäºé ã
HTTPãããã³ã«ã®æ°ããããŒãžã§ã³-HTTP / 2ã¯ããµã€ãã®èªã¿èŸŒã¿ãé«éåããããã«èšèšãããŠããŸãã ãã®ãããã³ã«ã¯æè¿ç»å ŽããçŸåšç©æ¥µçã«äœ¿çšãããŠããŸãïŒWebãµã€ãéã®å ±æã®çŽ20ïŒ ïŒã äžè¬çã«ãHTTP / 2ã«ã¯å®éã«ã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ã¡ã«ããºã ããããŸããäž»ãªãã®ã¯ãããŒãžã®èªã¿èŸŒã¿æéã«å¯Ÿãããããã¯ãŒã¯é 延ã®åœ±é¿ãæžããããšã§ãïŒãªã¯ãšã¹ãã®å€éåïŒã ãã ããHTTP / 2ã«ããé«éåã¯åžžã«æåãšã¯ã»ã©é ãããããã®ãããã³ã«ã«äŸåããªãã§ãã ããã
顧客ã®æé©å
ãµãŒããŒã®æé©åãšã¯ç°ãªããã¯ã©ã€ã¢ã³ãã¯ãŠãŒã¶ãŒã®ãã©ãŠã¶ãŒã§çºçãããã¹ãŠã察象ãšããŠããŸãã ãã®ãããå¶åŸ¡ã¯è€éã§ïŒããŸããŸãªããã€ã¹ããã©ãŠã¶ãŒïŒãæé©åã«ã¯ããŸããŸãªåéããããŸãã ã»ãšãã©ãã¹ãŠã®ãããžã§ã¯ãã§äœ¿çšã§ããæãå¹æçã§æ®éçãªæ¹æ³ãèŠãŠãããŸãã
ã¯ãªãã£ã«ã«ãã¹ã®æé©åïŒCSSãJS
ã¯ãªãã£ã«ã«ã¬ã³ããªã³ã°ãã¹-ãã©ãŠã¶ãŒã§ããŒãžã®ã¬ã³ããªã³ã°ãéå§ããããã®ãªãœãŒã¹ã®ã»ããã éåžžããã®ãªã¹ãã«ã¯ãHTMLããã¥ã¡ã³ãèªäœãCSSã¹ã¿ã€ã«ãWebãã©ã³ããããã³JSã³ãŒããå«ãŸããŸãã
ã¹ããŒããªããã£ãã€ã¶ãŒãšããŠã®ã¿ã¹ã¯ã¯ãæéïŒãããã¯ãŒã¯é 延ãèæ ®ïŒãšãã©ãã£ãã¯ïŒäœéæ¥ç¶ãèæ ®ïŒã®äž¡æ¹ã§ãã®ãã¹ãççž®ããããšã§ãã
ã¯ãªãã£ã«ã«ãã¹ã決å®ããæãç°¡åãªæ¹æ³ã¯ãChromeïŒéçºè ããã«ïŒã§ç£æ»ãéå§ããããšã§ããLighthouseãã©ã°ã€ã³ã¯ãäœéæ¥ç¶ãèæ ®ããŠãæ§æãšèªã¿èŸŒã¿æéã決å®ããŸãã
äž»ãªææ³ã¯ãã¯ãªãã£ã«ã«ãã¹ãåæžããããšã§ããäžèŠãªããŸãã¯å»¶æã§ãããã®ã¯ãã¹ãŠåé€ããŸãã ããšãã°ãã»ãšãã©ã®JSã³ãŒãã¯ãããŒãžãããŒãããããŸã§é 延ã§ããŸãã ãããè¡ãã«ã¯ãHTMLããã¥ã¡ã³ãã®æåŸã«JSãªãœãŒã¹åŒã³åºããé 眮ããããasyncå±æ§ã䜿çšããŸãã
CSSã®é 延ããŒãã®å ŽåãJSãä»ããŠåçã¹ã¿ã€ã«ã·ãŒãã䜿çšã§ããŸãïŒdomContentLoadedã€ãã³ããåŸ æ©ããåŸïŒã
Webãã©ã³ãã®æé©å
ä»æ¥ã®Webãã©ã³ãã®æ¥ç¶ã¯ãèšèšã®ã»ãŒæšæºã«ãªã£ãŠããŸãã æ®å¿µãªããããããã¯ããŒãžã®ã¬ã³ããªã³ã°é床ã«æªåœ±é¿ãåãŒããŸãã Webãã©ã³ãã¯ãããã¹ãã®ã¬ã³ããªã³ã°ãéå§ããåã«ååŸããå¿ èŠãããè¿œå ãªãœãŒã¹ã§ãã
å€ãã®å Žåããã©ã³ããã¡ã€ã«ãžã®ãã€ã³ã¿ãŒãCSSãã¡ã€ã«ã«åãããŠãããšããäºå®ã«ãã£ãŠç¶æ³ã¯æªåããŸãããCSSãã¡ã€ã«ãããã«ã¯æ¥ãŸããã å€ãã®éçºè ã¯ãå ¬éWebãã©ã³ããµãŒãã¹ïŒããšãã°ãGoogle FontsïŒã®äœ¿çšã奜ã¿ãŸããããã«ãããããã«å€§ããªé 延ïŒè¿œå ã®æ¥ç¶ãCSSãã¡ã€ã«ïŒãçºçããŸãã
æé©åã«ãŒã«ã¯ãWebãã©ã³ããã©ãã£ãã¯ã®ãµã€ãºãçž®å°ããã§ããã ãæ©ãååŸããããšã§ãã
ãã©ãã£ãã¯ãåæžããã«ã¯ãææ°ã®åœ¢åŒã䜿çšããå¿ èŠããããŸããææ°ã®ãã©ãŠã¶ã«ã¯WOFF2ãäºææ§ã«ã¯WOFFã䜿çšããŸãã ããã«ããµã€ãã§äœ¿çšãããŠããæåã»ããïŒã©ãã³èªãããªã«æåãªã©ïŒã®ã¿ãå«ããå¿ èŠããããŸãã
æ°ããä»æ§ãªã³ã¯rel = "preload"ãšCSS font-displayããããã£ã䜿çšããŠãWebãã©ã³ãã®é«é衚瀺ã«åœ±é¿ãäžããããšãã§ããŸãã ããªããŒãã«ããããã©ã³ããã¡ã€ã«ãã§ããã ãæ©ãããŠã³ããŒãããå¿ èŠãããããšããã©ãŠã¶ã«äŒããããšãã§ããŸãããŸããfont-displayã¯ããã¡ã€ã«é 延ã®å Žåã«ãã©ãŠã¶ã®åäœãå¶åŸ¡ããããã®æè»ãªãªãã·ã§ã³ãæäŸããŸã
ç»åã®æé©å
ç»åã¯ãçŸä»£ã®ãµã€ãã®ééã®å€§éšåãå ããŠããŸãã ãã¡ãããç»åã¯ããŒãžã«ãšã£ãŠCSSãJSã³ãŒãã®ãããªéèŠãªãªãœãŒã¹ã§ã¯ãããŸããã ããããå€ãã®ãµã€ãã§ã¯ãç»åãã³ã³ãã³ãã®éèŠãªéšåãæ§æããŠããŸãããªã³ã©ã€ã³ã¹ãã¢ã®è£œåã«ãŒããèŠããŠãããŠãã ããã
ç»åãæé©åããããã®äž»ãªææ³ïŒãµã€ãºãçž®å°ããŸãã ãããè¡ãã«ã¯ãæ£ãã圢åŒãšå§çž®ããŒã«ã䜿çšããŸãã
- éæ床ãšããã¹ããå«ãç»åã®PNGã
- åçããã³è€éãªç»åã®JPEGã
- ãã¯ãã«ã°ã©ãã£ãã¯çšã®SVGã
ãããã®åœ¢åŒã«å ããŠãGoogleã®WebPãªã©ã®æ°ãã圢åŒãéçºãããŠããŸãã ãã®åœ¢åŒã¯ãPNGããã³JPEGã®äœ¿çšé åãã«ããŒã§ããŸã-éå¯éããã³å¯éå§çž®ãéæ床ãããã«ã¯ã¢ãã¡ãŒã·ã§ã³ããµããŒãããŸãã ããã䜿çšããã«ã¯ãWebPã§ç»åã®ã³ããŒãäœæãããããããµããŒããããã©ãŠã¶ãŒã«æäŸããã ãã§ååã§ãã
PNGã«ã¯ãOptiPNGãPNGoutãectãªã©ããµã€ãºãçž®å°ããããã«äœ¿çšã§ããå€ãã®æé©åããŒã«ããããŸãã ãŸããzopfliPNGã䜿çšããŠãããŒã¿å§çž®ã®å éšæé©åãå®è¡ã§ããŸãã ãã®ãããªãœãããŠã§ã¢ã®äž»ãªã¢ã€ãã¢ã¯ãæé©ãªå§çž®ãã©ã¡ãŒã¿ãéžæããŠããã¡ã€ã«ããäœåãªããŒã¿ãåé€ããããšã§ãã ããã§æ³šæããå¿ èŠããããŸãïŒäžéšã®ãŠãŒãã£ãªãã£ã«ã¯ãå質ãäœäžããã¢ãŒãããããŸãããããã¯ããªãã«é©ããŠããªãå¯èœæ§ããããŸãïŒåºåã§ãŸã£ããåãç»åãæåŸ ããå ŽåïŒ
JPEGæé©åã¯ãéå¯éãšå¯éã®2ã€ã®ã¿ã€ãã«åããããŸãã éåžžãMozilla JPEGããã±ãŒãžããå§ãããŸãããã®ããã±ãŒãžã¯ããã®åœ¢åŒã§ã®å§çž®ãæ¹åããããã«ç¹å¥ã«èšèšãããŠããŸãã ãã¹ã¬ã¹æé©åã®å Žåã¯ãjpegtranã䜿çšããŠãæ倱ãã-cjpegã䜿çšã§ããŸãã
ãã£ãã·ã³ã°ããããŒ
ããã¯æãåçŽãªã¯ã©ã€ã¢ã³ãæé©åææ³ã§ãã ãã®æå³ã¯ããã©ãŠã¶ãã»ãšãã©å€æŽãããªããªãœãŒã¹ããã£ãã·ã¥ããããšã§ãïŒç»åãCSSããã³JSãã¡ã€ã«ããã©ã³ããæã«ã¯HTMLææžèªäœã§ãã ãã®çµæãåãªãœãŒã¹ã¯ãµãŒããŒããäžåºŠã ãèŠæ±ãããŸãã
Nginxã䜿çšããŠããå Žåã¯ããã£ã¬ã¯ãã£ããè¿œå ããã ãã§ãïŒ
add_header Cache-Control "max-age=31536000, immutable";
ãã®æç¹ããããã©ãŠã¶ã«ã¯æ倧1幎éïŒã»ãŒæ°žä¹ ã«ïŒãªãœãŒã¹ããã£ãã·ã¥ããæš©å©ããããŸãã æ°ãããã©ã¡ãŒã¿ãŒãäžå€ãã¯ããªãœãŒã¹ãå€æŽãããäºå®ããªãããšã瀺ããŸãã
ãã¡ãããçåãçããŸãããã£ãã·ã¥ããããªãœãŒã¹ãå€æŽããå¿ èŠãããå Žåã¯ã©ãã§ããããã çãã¯ç°¡åã§ããã¢ãã¬ã¹ãURLãå€æŽããŸãã ããšãã°ããã¡ã€ã«åã«ããŒãžã§ã³ãè¿œå ã§ããŸãã HTMLããã¥ã¡ã³ãã®å Žåããã®æ¹æ³ãé©çšã§ããŸãããååãšããŠãããçããã£ãã·ã¥æéã䜿çšãããŸãïŒããšãã°ã1åãŸãã¯1æéïŒã
ããŒã¿å§çž®
å¿ é ã®ãã©ã¯ãã£ã¹ã¯ããµãŒããŒãããã©ãŠã¶ã«éä¿¡ãããšãã«ããã¹ãããŒã¿ãå§çž®ããããšã§ãã ã»ãšãã©ã®WebãµãŒããŒã«ã¯ãgzipå¿çå§çž®ã®å®è£ ããããŸãã
ãã ããåã«å§çž®ãã¢ã¯ãã£ãåããã ãã§ã¯ååã§ã¯ãããŸããã
第äžã«ãå§çž®çã¯èª¿æŽå¯èœã§ãããæ倧ã«è¿ãã¯ãã§ãã
第äºã«ãéçå§çž®ã䜿çšã§ããŸããã€ãŸãããã¡ã€ã«ãäºåã«å§çž®ãããã£ã¹ã¯ã«ä¿åããŸãã 次ã«ãWebãµãŒããŒã¯å§çž®ããŒãžã§ã³ãæ€çŽ¢ããããã«ãããæäŸããŸã第äžã«ãããå¹ççãªå§çž®ã¢ã«ãŽãªãºã ã䜿çšã§ããŸãïŒzopfliïŒgzipãšäºææ§ããïŒããã³brotliïŒæ°ããå§çž®ã¢ã«ãŽãªãºã ïŒã Brotliã¯HTTPSã§ã®ã¿åäœããŸãã ãããã®ã¢ã«ãŽãªãºã ïŒç¹ã«zopfliïŒã¯å§çž®ã«ã³ã¹ããããããããéçããŒãžã§ã³ã§ã¯ééããªã䜿çšããŸãã
ãã¡ã€ã«ã®å§çž®å¹æãæ倧åããããã«ããããã¡ã€ããã»ã¹ãäºåã«é©çšãããŸããäžèŠãªæ¹è¡ãã¹ããŒã¹ããã®ä»ã®äžèŠãªæåã®ã¯ãªãŒãã³ã°ã§ãã ãã®ããã»ã¹ã¯å圢åŒã«åºæã§ãã ãŸãããµã€ãäžã®ä»ã®ããã¹ãããŒã¿ã®å§çž®ã«ã泚æããå¿ èŠããããŸãã
CDNã䜿çšãã
ãŠã§ããµã€ãã®é«éåã«CDNïŒã³ã³ãã³ãé ä¿¡ãããã¯ãŒã¯ïŒã䜿çšããããšã¯ãæè¡ã®æ¬è³ªã«å€ãã®ããŒã±ãã£ã³ã°ã®æ®»ãä»ãããéåžžã«å ¬è¡šãããæ段ã§ãã
çè«ïŒãªã
ããšããšãCDNã¯ãæŸéã¡ãã£ã¢ãµã€ãã®ã€ã³ã¿ãŒããããã£ãã«ããªãããŒãããããã«èšèšãããŠããŸããã ããšãã°ãã©ã€ããããªãèŠèŽããå Žåãæ°å人ã®èŠèŽè ããµãŒããŒã®åž¯åå¹ ã«éåžžã«å€§ããªè² è·ããããŸãã ããã«ãã¯ã©ã€ã¢ã³ããšãµãŒããŒéã®è·é¢ãé·ãå Žåã«éä¿¡ã®äžæã®ãªãå質ã確ä¿ããããšã¯éåžžã«å°é£ã§ãïŒé 延ãšãããã¯ãŒã¯ã®äžå®å®æ§ã®ããïŒã
ãã®åé¡ã®è§£æ±ºçã¯ãCDNãã€ãŸãã¯ã©ã€ã¢ã³ãïŒãã¥ãŒã¢ãªã©ïŒãæ¥ç¶ããããã®ãããã¯ãŒã¯ã®ãã¹ããæ¢ã«ãµãŒããŒïŒãªãªãžã³ïŒã«æ¥ç¶ãããŠããåæ£ãããã¯ãŒã¯ãäœæããããšã§ããã åæã«ããµãŒããŒãžã®æ¥ç¶æ°ã¯1ã€ïŒæ°åïŒã«åæžããããããã¯ãŒã¯ã«ããã³ã³ãã³ãã®ãã£ãã·ã¥ã«ããCDNãžã®æ¥ç¶æ°ã¯æ°çŸäžã«éããå¯èœæ§ããããŸããã
çŸåšãã»ãšãã©ã®CDNã¯ãäž»ã«ã³ã³ãã³ãããã¯ã©ã€ã¢ã³ãïŒãµã€ã蚪åè ïŒãŸã§ã®è·é¢ãçãããããšã«ããããµã€ããå éããæ段ãšããŠäœçœ®ä»ããŠããŸãã
èããããå¹æ
CDNã䜿çšããŠãµã€ããé«éåããã«ã¯ã©ãããã°ããã§ããïŒ
ã¯ãããŠãŒã¶ãŒã¯ååãšããŠããããã¯ãŒã¯äžã®æãè¿ãïŒã¢ã¯ã»ã¹æéã§ïŒãµãŒããŒã«å®éã«æ¥ç¶ããTCPããã³TLSæ¥ç¶ã確ç«ããé«éããã»ã¹ãåãåããŸãã ããã«ãã³ã³ãã³ããCDNãµãŒããŒäžã«ããå ŽåããŠãŒã¶ãŒã¯ããã«ãããåä¿¡ã§ããŸãã ãããã£ãŠãç¬èªã®ãµãŒããŒã®è² è·ã軜æžãããŸãã
第äºã«ãCDNã¯ã³ã³ãã³ããå€æŽããã«é ä¿¡ã§ããã ãã§ãªãããã®åŽã§æé©åããŠããã³ã³ãã¯ããªåœ¢åŒã§ã¬ã³ããªã³ã°ã§ããŸãïŒç»åã®å§çž®ããã¹ããžã®å§çž®ã®é©çšãªã©ããã®ãããªæé©åã«ãããããŠã³ããŒãæéãççž®ã§ããŸãã
CDNã䜿çšããããšã®æ¬ ç¹
éåžžã®æ¬ ç¹ã¯ãå©ç¹ãç¶ãããšã§ãããªããžã§ã¯ããCDNããŒãã®ãã£ãã·ã¥ã«ãªãå ŽåããããŸãã ããšãã°ããŸã èŠæ±ãããŠããªããããã£ãã·ã¥ã§ããŸããïŒHTMLããã¥ã¡ã³ãïŒã ãã®å ŽåãCDNãšãµãŒããŒã®éã§è¿œå ã®é 延ãçºçããŸãã
CDNã¯ãµã€ããžã®ã¢ã¯ã»ã¹ãé«éåããããã«èšèšãããŠãããšããäºå®ã«ããããããããããã¯ãŒã¯ã«ãŒããCDNããªãå Žåãããæé©ã§ãªãå ŽåããããŸãã ç¹ã«ãã·ã¢ãåªå åžå Žã§ã¯ãªãã°ããŒãã«CDNã«é¢é£ããŠããŸãã
æåŸã«ãã³ã³ãã³ãé ä¿¡ãããã¯ãŒã¯ã¯éåžžã«è€éãªã·ã¹ãã ã§ãããä»ã®å Žæãšåæ§ã«ãé害ãäžå®å®æ§ãããã³ãã®ä»ã®åé¡ãçºçããå¯èœæ§ããããŸãã CDNã䜿çšããŠãå¥ã®ã¬ãã«ã®è€éããè¿œå ããŸãã
çµæãä¿®æ£ããŸã
è¯ããµã€ãé床ã¡ããªãã¯ãéæã§ãããšããŸãããã ãŠãŒã¶ãŒãšãªãœãŒã¹ææè ã¯æºè¶³ããŠããŸãã ããã§ãé床ã®åé¡ãå¿ããããšãã§ããŸããïŒ ãã¡ããéããŸãã ãµã€ãã®å質ãäžå®ã«ä¿ã€ã«ã¯ãåžžã«ãµã€ããç¶æããç£èŠãå®æœããå¿ èŠããããŸãã
å éãµããŒã
ã©ã€ãWebãããžã§ã¯ãã¯å®æçã«æŽæ°ãããäžè¬çãªãã³ãã¬ãŒãïŒãã¶ã€ã³ããŒããã€ã³ã¿ãŒãã§ã€ã¹ïŒãããã³ã³ã³ãã³ãã®äž¡æ¹ã§å€æŽãçºçããŸãã ããã°ã©ã ã³ãŒãïŒã¯ã©ã€ã¢ã³ããšãµãŒããŒã®äž¡æ¹ïŒãç©æ¥µçã«å€æŽãããŠããŸãã
åå€æŽã¯ããµã€ãã®é床ã«åœ±é¿ãäžããå¯èœæ§ããããŸãã ãã®åœ±é¿ãå¶åŸ¡ããã«ã¯ãéçºæ®µéã§ãµã€ãã®é床ãç£èŠããããã®åæã·ã¹ãã ãå°å ¥ããå¿ èŠããããŸãã ãããã£ãŠããŠãŒã¶ãŒãæ°ã¥ãåã«é床ã®åé¡ãææ¡ã§ããŸãã
åä¿¡ã³ã³ãã³ããæé©åããã«ã¯ãæé©åæé ãã³ã³ãã³ã管çã·ã¹ãã ã«çµ±åããå¿ èŠããããŸãã ãŸããããã¯ç»ååŠçã«é¢ãããã®ã§ãã
ãµã€ãã®é«éåã¯éåžžã«ãã€ãããã¯ãªé åã§ããæ°ããæšæºãç»å Žãããã©ãŠã¶ã®ãµããŒããå€åããŠããŸãã ãããã£ãŠããããžã§ã¯ãã®æè¡ãããã»ã¹ã䜿çšãããŠãããœãããŠã§ã¢ãå®æçã«ç¢ºèªããããšãéèŠã§ãã
ãŠãŒã¶ãŒã®å®éã®é床ãç£èŠãã
çæ³çãªå®éšå®€æ¡ä»¶äžã§ã®åæãã¹ãã¯ãã·ã¹ãã ã³ãŒãã®å€æŽãè©äŸ¡ããã®ã«éåžžã«åœ¹ç«ã¡ãŸãããããã ãã§ã¯äžååã§ãã æçµçã«ãç§ãã¡ã¯ãµã€ããå®éã®ãŠãŒã¶ãŒã®ããã«çŽ æ©ãåäœããããšãæã¿ãŸãã ãã®ãããªããŒã¿ãåéããããã«ããŠãŒã¶ãŒåŽã§é床ç£èŠãè¡ãããŸãïŒRUM-å®éã®ãŠãŒã¶ãŒç£èŠïŒã
RUMãæŽçããã«ã¯ãWebåæã·ã¹ãã ïŒYandex.MetricaãGoogle AnalyticsïŒã®ãããããæ¥ç¶ããŠããµã€ãã®èªã¿èŸŒã¿æéã«é¢ããã¬ããŒãã衚瀺ããŸãã ãã詳现ã§æ£ç¢ºãªããŒã¿ã«ã€ããŠã¯ãå°çšã®é床ç£èŠãµãŒãã¹ã䜿çšã§ããŸãã
çµè«
ãŠã§ããµã€ãé«éåæ¥çã¯ããŠã§ãéçºã®ããªãè¥ãæ¥çã§ãããç©æ¥µçã«çºå±ããŠããŸãã ãªã³ã©ã€ã³ããžãã¹ã®ãµã€ãé床ã®éèŠæ§ã¯ãã§ã«æããã§ããã競äºã®èŠå ã®1ã€ã«ãªãã€ã€ãããŸãã ãã®ããããµã€ãã®é床ãæé©åãããã®åéã«æè³ãã䟡å€ããããŸãã
ãµã€ãã®é床ã®ãããã¯ã¯åºç¯ã§ããããµãŒããŒã³ãŒãããã³ã³ãã³ããŸã§ãWebã¢ããªã±ãŒã·ã§ã³ã®éçºãšãµããŒãã®å€ãã®åŽé¢ã«åœ±é¿ãäžããŸãã ããã¯ãéçºããŒã ã®é¢äžãªãã«è¯ãçµæãåŸãããšãäžå¯èœã§ããããšãæå³ããŸãã
æãéèŠãªããšïŒãŠãŒã¶ãŒã«ã€ããŠèŠããŠãããŠããµã€ãã®ããŸããŸãªäœ¿çšæ¡ä»¶ãèæ ®ã«å ¥ããŠãã ããã Webãµã€ãã®é«éåã¯ããããžã§ã¯ãã®ã©ã€ããµã€ã¯ã«å šäœã§ããŸããŸãªåŒ·åºŠã§è¡ãããããã»ã¹ã§ãã