ISUCON7ã«åºã #isucon
ISUCON7ã«åå ãã¾ãã
ä»å¹´ã¯åè·ã®å 輩ã¨ç¾è·ã®å 輩ã¨çµãã§åå ãã¾ããã
çµæ
äºé¸çªç ´ã®20ä¸å°ã«ã¯é ãåã°ãâ¦
ç¹æ°ã®ãã¬ã大ãããã¦ã©ã®å¯¾çãå¹ãããå ¨ç¶ããããªãã£ããã©æç³»åã§ãã£ããã¨ã¨ãããããã£ããã©è«¦ãããã¨ãã¡ã¢ãã
ã¿ã¤ã ã©ã¤ã³
ç§ã®æ å½ã¯ã¢ããªã±ã¼ã·ã§ã³ã ã£ãã
- INDEX追å
(user.name)
(message.id, message.channel_id)
(haveread.user_id, haveread.channel_id)
SELECT *
ã®æ²æ»get_channel_list_info
ã®ç½®ãæã- æçµçã«ä¸ç®æããæ®ããªãã£ã
- DBã¢ã¯ã»ã¹ããåã«çµæè¿ããã¨ããã¯è¿ã
- DBã¢ã¯ã»ã¹ããå¾ã«ãªã¯ã¨ã¹ããã©ã¡ã¼ã¿ã®æç¡ãã§ãã¯ãã¦ããããªãã¸ãã¯ãã¡ããã¡ãããã£ã
COUNT(*)
ãCOUNT(1)
ã«- ãã£ã³ãã«ãã¨ã®ã¡ãã»ã¼ã¸æ°ã«ã¦ã³ããå°ç¨ãã¼ãã«ç¨æãã¦ç½®ãæã
- æ¯å
COUNT
ããã«SELECT
ããã ãã§ãããªã£ã - æåã®æ®µéã§2çªãã«é ãã¯ã¨ãªã ã£ãã®ã§æãã¤ãã
- æ¯å
- php-fpmã®ãã¥ã¼ãã³ã°
- 使ããªãPHP extensionã®åé¤
xdebug.so
, ãåã®ãã¨ãã§
N+1
ãããã¤ãæ½°ã
ä»ã®ãäºäººã«ã¯
- ããã«ã¦ã§ã¢(MySQL, nginxç)ã®ãã¥ã¼ãã³ã°
- ç»åã®è±DBå
N+1
æ²æ»- HTTP/2å
ã¨ã諸ã ãã£ã¦ããã£ããæè¬â¦
ããããã£ããã©ã§ããªãã£ã
/register
,/login
ãã¼ã¸ãéçã³ã³ãã³ãã«- ãã¸ãã¯è¦ãã¨åãããã©ãã®2ã¤ã¯PHPã«æãããå¿ è¦ããªã
- HTMLã®é ç½®ã¯ä¸ç¬ã ã£ããã©åªå 度ä½ãã£ãã®ã§å¾åãã«ããã®ã¨ãnginxã®è¨å®ã§ããã£ã¦ãããªãã£ã
- ãã£ãã·ã¥ããã«ã¦ã§ã¢ã®è¿½å
- ãã°ã¤ã³å¤å®ã®åº¦ã«
select * from user
ãã¦ãã®ã¨ã - ä»åã¯åé¤æ´æ°ãç¡ãã£ãã®ã§æ´åæ§ã®æ ä¿ãé£ãããªãã£ãã¯ãâ¦
- ãã°ã¤ã³å¤å®ã®åº¦ã«
- ã¡ãã»ã¼ã¸åå¾ãã¸ãã¯æ¹å
- æªèªæ°ã«ã¦ã³ããã¸ãã¯ä¿®æ£
- ãã£ã¡ãã¡ãã»ã¼ã¸æ°ã¨åãããã«ã«ã¦ã³ããã¼ãã«ç¨æãããã¨æã£ããã©åæã¬ã³ã¼ãã100*1100ã«ãªã£ã¦ãã¾ããã¨ãadd_messageãããã¨1100ã¬ã³ã¼ãã«updateãèµ°ãã®ã§è«¦ãã
- ã¹ã®ã£ããã¨ãã¯ã¹ãã¼ã ã®sugyanãããå¥ã¢ããã¼ãã§è§£æ±ºãã¦ã¦æ¬å½ã«å¿ã®åºããæããæ°æã¡â¦
- æ¢èªæ°ãã«ã¦ã³ããã¦ç·ã³ã¡ã³ãæ° - æ¢èªæ°ããã°æªèªæ°ã«ãªã
- ãããªãåæã¬ã³ã¼ããããªã
LIMIT
,OFFSET
殺ã- php-fpmã®ãããªã調æ´
- æéç¡ãã¦ããªãéã«èª¿æ´ãã
- PHPã¨MySQLã®ã³ãã¯ã·ã§ã³æé©å
ä»ã«ãè²ã ã¢ã¤ãã£ã¢ã¯ãã£ã¦
- DBãµã¼ãã«ãã¢ããªãç«ã¦ã
- ãã£ãã·ã¥ç¨ãµã¼ãã¨ã¢ããªãåãã
ãªãã¦æ¡ããã£ããã©ã¨ã«ãããã«ãããã«ããã¯ã/icons
ããä»ã«ç§»ããªãã¦æ»ãã ã
ææ
ã¨ã«ãããã«ã/icons
ã®ãªã¯ã¨ã¹ããæãã¦ç¡ãã¦ããã©ãã£ãã
ä¸çªæåã¯DBãå®å ¨ã«ãµãã£ã¦ã¦ãã®å£ã¯ä¸ç¬ã§è¶ãããããã©ãã®å¾ããã«ç»åãæ»ãã§ããã¨ãåãã£ã¦ãªãã»ã©ã¨ããæãã ã£ãã
ç»åã®è±DBåããã¦ãããã¾ã§ã¹ã«ã¼ããããä¸ãããããªããªãè¦ããã£ãã
ä»åã¯ãããæãããã¼ã ã10ä¸ã®å£ãè¶ãã¦ãã£ãã®ã§ã¯ã¨ããæ¨æ¸¬ã
ã¹ã®ã£ããã¨ãã¯ã¹ãã¼ã ã¨åãä¼å ´ã§è§£ãã¦ãã®ã§å¹ããã¨ããCache-Control
ãããããããããã£ã¦2åç®ä»¥éãªã¯ã¨ã¹ããããªãããã«ãã¦ããããããã¬ã¬â¦
ä¸æ¨å¹´ãæ¨å¹´åå ãã¦ä»å¹´3åç®ã ãã©è¨æ¸¬ãã¦ããã«ããã¯ç¹å®ãã¦ç¢ºå®ã«è½ãã¤ã¶ãã¦ããåã¯ã¤ãã¦ããã¨æãã¦ã¦ãããããã«çµæ§æããã
ãã¨ã¯ã±ã£ã¨ç´ããã³ã¼ãã«ãã°ããããã¨ãå¤ãã¦çµæ§æéãåãããã
ä»åã¯ã»ã¼ä½ãæºåã§ããªãã£ããã©æ¥å¹´ã¯æå ã§ç°¡åã«ã¢ããªãåããããããªç°å¢ãä½ãç§ä¼ã®ã¿ã¬ãç¨æãã¦ããã§ãããã°ãããã
ã¨ã«ããã§ãã
æ¥å¹´ãã100ä¸å使ã£ã¦æ¸©æ³è¡ãããã§ãã