MySQL5.6ã¨5.7ã®ã¡ãã£ã¨ããéãã¨innodb_thread_concurrencyã®å½±é¿
ãã®è¨äºã¯MySQL Casual Advent Calendar 2016ã®22æ¥ç®ã§ãã
innodb_thread_concurrencyãæè¿ã®ããã©ã«ãã§ãã0ã¨è«çCPUã³ã¢æ°ã®2åã®48ã«è¨å®ããå ´åã«è¦³æ¸¬åºæ¥ãå°ãã¿ã§ãããã³ããã¼ã¯ã®tpsãè¼ãã¦ãã¾ããã1åããåå¾ãã¦ãªãã®ã§ãå²ã¨èª¤å·®ãããã¨èãããããããç®å®ç¨åº¦ã«è¦ã¦ãã ããã
- ç°å¢
- ãã³ããã¼ã¯ãã¼ã«
- sysbench 0.5 (oltp.lua)
- å®è¡ã¹ã¬ããæ°(8, 16, 32, 64, ... , 2048, 4096)
- ãã³ããã¼ã¯å®è¡ã³ãã³ã(以ä¸ãã¹ã¬ããæ°1ãã512ã¾ã§8ååæå®è¡)
- 1ã±ã¼ã¹å®è¡æ¯ã«150ç§éã®Sleepãå ¥ãã¦ãã¾ãã
LD_PRELOAD=/usr/lib64/libjemalloc.so.1 \ /usr/local/sysbench-0.5/bin/sysbench \ --test=/usr/local/sysbench-0.5/lua/oltp.lua \ --rand-init=on --db-driver=mysql --oltp-read-only=off \ --rand-type=uniform \ --oltp-tables-count=18 --oltp-table-size=3000000 \ --mysql-socket=/var/lib/mysql/mysql.sock \ --mysql-db=sbtest5 \ --mysql-user=sbtest --mysql-password=sbtest-pw \ --max-time=300 --max-requests=0 \ --num-threads=$thread \ run
ä¸è¨æ¡ä»¶ã§ãã³ããã¼ã¯ãè¡ãªã£ãéã®ã°ã©ãã¯ä»¥ä¸ã®ããã«ãªãã¾ã(ã¢ãã¿ãªã³ã°éé15ç§)ã
å·¦ãã5.7ã®innodb_thread_concurrency 48 / 0, 5.6ã®innodb_thread_concurrency 48 / 0ã®çµæã§ãã
5.7å´ã®DMLãã¸ã°ãµã°ãã¦ãã¦å®å®æãããã¾ãããã¾ãã(èªåã®è¦³æ¸¬ç¯å²ã§)ãã¾ã使ããã¦ãªã以ä¸ãè¨å®ãã¦ãã¾ãã
innodb_max_purge_lag_delay=1000000 innodb_max_purge_lag=100000
ãã¡ãã®è¨å®ããã£ããæ¸ãã¨ãSHOW ENGINE INNODB STATUS\G ãå®è¡ããéã«ç¢ºèªã§ããHistory list lengthãinnodb_max_purge_lagã®è¨å®å¤(100000)ã«åã¾ãããã«ãããã¨ãã¾ãã
ãã®çµæãinnodb_thread_concurrencyã48ã®å ´åã¯åã¾ããããªçµæã¨ãªã£ã¦ãã¾ãããinnodb_thread_concurrencyã0ã®å ´åã¯åã¾ããã«ä¼¸ã³ç¶ãã¦ãã¾ããHistory list lengthã¯å¤ãã¦ã5000以ä¸ç¨åº¦ã«åã¾ãã®ãæã¾ãããã¨èãã¦ãã¾ããä¸å®ä»¥ä¸ã®å¤§ããã«ãªãã¨å²ã¨æ§è½ãä¸ããå¾åã«ããããã§ãããã£ã¦ãinnodb_max_purge_lagã®å¶å¾¡ãè¡ãããç¶æ
ã¯ãã¾ãè¯ãããã¾ããã
ãã ãä»åã®çµæãè¦ãã¨å
¨é¨ã¡ã¢ãªã«è¼ãç¶æ
ã ã¨æ§è½ã¸ã®å½±é¿ã軽微ãªã®ããããã¾ãããLinkBenchã§ã¡ã¢ãªã«è¼ãåããªãå ´åã§ã¯10000è¶
ãããããã§çµæ§æ§è½ä½ä¸ããäºãããã®ã§ãã®ä»ã®è¦å ã¨é¢é£ãããããã§ãã
ã¾ãcheckpoint ageã5.6ã¯150ç§éã®ã¹ãªã¼ãã®éã«æ¸å°ãã¦ãã¾ããã5.7ã§ã¯innodb_io_capacityã®è¨å®å¤ã«æºãã¦æ¸ãåºããè¡ãããæ¸å°ããããªãç¶æ
ã¨ãªã£ã¦ãã¾ã(5.6ã¯innodb_io_capacityã®å¶å¾¡ãå²ã¨éãªãã)ã
ãâ»å®å
¨ã«åãæ¡ä»¶ãããªããã¨è¨ãããã¨å®éããã§ã
ã¨ã¯ãããã£ã¹ã¯I/Oããã¾ãå¼·ããªãç°å¢ã§å¤§éã®æ¥ç¶ã»æ´æ°ãè¡ãããå ´åãinnodb_thread_concurrencyã48ã«ãããã¨ã§History list lengthã®ä¼¸ã³ãæå¶åºæ¥ããããã³ããã¼ã¯å¾ã®ibdata1ã®ãµã¤ãºã¯çµæ§ãªå·®ãåºã¾ãã
以ä¸ãã³ããã¼ã¯å¾ã®ibdata1ã®ãã¡ã¤ã«ãµã¤ãºã§ãã
5.7 ccr 48 | 5.7 ccr0 | 5.6 ccr48 | 5.6 ccr0 |
---|---|---|---|
268MB | 780MB | 204MB | 460MB |
5.7ã®æ¹ãibdata1ã®ãµã¤ãºã大ããã®ã¯ãåç´ã«5.6ããtpsãé«ããå¦çéãå¤ãããã§ãã
以ä¸sysbenchã®tpsã§ãã
ã¹ã¬ããæ° | 5.7 ccr48 | 5.7 ccr0 | 5.6 ccr48 | 5.6 ccr0 |
---|---|---|---|---|
8 | 2133.73 | 2176.16 | 2085.15 | 2130.29 |
16 | 3454.79 | 3454.86 | 3378.4 | 3433.78 |
32 | 3860.71 | 3920.18 | 3637.29 | 3665.24 |
64 | 4077.97 | 4300.74 | 3659.85 | 3731.46 |
128 | 4529.18 | 4623.69 | 3669.78 | 3755.15 |
256 | 4669.99 | 4714.38 | 3648.23 | 3655.07 |
512 | 4416.23 | 4466.67 | 3614.36 | 3729.47 |
1024 | 4683.41 | 4634.53 | 3520.22 | 3585.23 |
2048 | 4460.89 | 4590.36 | 3407.69 | 3499.41 |
4096 | 4253.65 | 4435.6 | 3049.28 | 3343.77 |
ã¨ãããã¨ã§ã¸ã°ã¶ã°ãªã°ã©ãã®å²ã«5.7ã®æ¹ããã¼ã¿ã«ã§è¦ãã¨æ§è½ãåºã¦ãããã¨ã«ãªãã¾ããããããããã¿ã¤ãã³ã°ãåãåãã°5.6ããæ§è½ãåºã¦ããªãç¶æ ã表ãã¦ãã¾ãã
ã§ã¯5.7ã§å®å®ãããããã«ã¯ä½ããããè¯ãã§ãããããæ§è½ãä¸ããã¿ã¤ãã³ã°ã§ã¯checkpont ageãå¼µãä»ãã¦ãã¦ãibdãã¡ã¤ã«ã¸ã®ãã©ãã·ã¥ãåä½ãã¦ããã¨èãããã¾ããä¾ãã°ib_logfileç³»ãtmpfsã«ç½®ãã¨ããI/Oå¼·ãã«ããã°è¯ãã®ã¯ããã¯ãããªãã§ãããããåºæ¥ãç°å¢ã¨ã¯éãã¾ãããä»åã®ã±ã¼ã¹ã¯5.6ã®è¨å®ãã»ã¼ãã®ã¾ã¾5.7ã§ä½¿ç¨ãã¦ããäºãæªãã®ã§ããã©ã¡ã¼ã¿èª¿æ´ãè¡ãã¾ãã
æµç¨ãããããªã±ã¼ã¹ã¯ãã¼ã¸ã§ã³ã¢ãããå¤ããã¨æãã¾ãã®ã§ããã®ã¿ã¤ãã³ã°ã§èª¿æ´ãè¡ããå¯è½æ§ãé«ããã¨æãã¾ãã
ã¨ããäºã§ãã©ãã·ã¥ããã£ã¨ãã£ãããããã°è¯ãã®ã§ã·ã³ãã«ã«ib_logfileãå¢ããã¾ãã
innodb_log_files_in_group = 12
ããã§ib_logfile0ããib_logfile11ã¾ã§ã®åè¨12GBã«ãªãã¾ãããã®ç¶æ ã§5.7ã®ã¿ãã³ããã¼ã¯ãååå¾ããã°ã©ãã¨tpsã¯ä»¥ä¸ã®ããã«ãªãã¾ããåå¾é ãééãã¦ã¦ãä»åã¯å·¦ãinnodb_thread_concurrency 0, å³ãinnodb_thread_concurrency 48ã¨ãªãã¾ãã
ã¹ã¬ããæ° | 5.7 ccr48 | 5.7 ccr0 |
---|---|---|
8 | 2262.15 | 2289.72 |
16 | 4214.03 | 4231.89 |
32 | 5476.94 | 5492.78 |
64 | 5757.04 | 5772.37 |
128 | 5805.44 | 5817.16 |
256 | 5732.35 | 5751.25 |
512 | 5810.34 | 5830.87 |
1024 | 5930.8 | 5744.61 |
2048 | 5785.43 | 5656.04 |
4096 | 5523.51 | 5536.83 |
å®å®ããçµæãtpsã¯æ´ã«ä¸æãcheckpoint ageãå¼µãä»ããã¨ãããã¾ãããã¨ã¯ããinnodb_thread_concurrencyã0ã®å ´åãç¸å¤ãããHistory list lengthã¯ä¼¸ã³ã¾ãããã®è¾ºãã¾ã§æ¥ãã¨H/Wã®å¤æ´ãç¡çã ã¨Durabilityä¸ãããããªãã®ããªã¼ãã¨æãã¾ã(doublewriteæ¢ããã¨ã)ã
é©åã«ib_logfile(REDO)å¢ããããinnodb_thread_concurrency, innodb_max_purge_lagãè¨å®ããäºã§å»¶å½åºæ¥ãå¯è½æ§ãããã¾ããã¡ã¢ãªå¤§éã«ç©ãã§ã¦ããããã¡ã«ãã¼ã¿ãINDEXãè¼ãããå¦çã¯ä½è£ã ãã¼ãã¨æ²¹æãã¦ãã¨5.7ã®ç°å¢ã§ib_logfileãå°ãªãå ´åãæ°ä»ããªãã¿ã¤ãã³ã°ã§ã¹ãã¼ãã¦ã³ãã¦ãå¯è½æ§ãããã®ã§ã注æãã ãããç¹ã«ã¢ãã¿ãªã³ã°ééã5åã¨ãã ã¨åãããå¯è½æ§ãé«ãã§ãã
ãªããåç´ã«undoé åãè¥å¤§åããã®ãã©ãã«ããããã ãã§ããã° innodb_undo_directory, innodb_undo_tablespaces, innodb_undo_log_truncate ã¨ãè¨å®ãã¦ããæ¹ãç¹ã«5.7ã«ããã¦ã¯è¯ãã¨æãã¾ãã
ã¨ããæãã§ãã5.6ã¨5.7ã®éããinnodb_thread_concurrencyã0以å¤ã«ããæ¹ãè¯ãã±ã¼ã¹ã«ã¤ãã¦ç¥ã£ã¦ããã¦é ããã°å¹¸ãã§ãã
ææ¥ã¯@yoku0825ããã«ãããCOUNTãéãããï¼ï¼ï¼SQL1æ¬ãã㯠ãã®2ãã§ãã