{"id":17003,"date":"2018-07-03T13:25:46","date_gmt":"2018-07-03T04:25:46","guid":{"rendered":"http:\/\/labs.gree.jp\/blog\/?p=17003"},"modified":"2021-10-08T19:12:05","modified_gmt":"2021-10-08T10:12:05","slug":"post17003","status":"publish","type":"post","link":"https:\/\/labs.gree.jp\/blog\/2018\/07\/17003\/","title":{"rendered":"innodb_thread_concurrency\u306b\u95a2\u3059\u308b\u8a71"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u308f\u3002\u305b\u3058\u307e\u3067\u3059\u3002\u4eca\u56de\u306e\u8a71\u306f\u8efd\u304f\u66f8\u3053\u3046\u3068\u601d\u3063\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u9577\u304f\u306a\u308a\u307e\u3057\u305f\u3002\u307e\u3041InnoDB\u306e\u8a71\u306a\u306e\u3067\u3057\u3087\u3046\u304c\u306a\u3044\u3067\u3059\u306d\u3002<\/p>\n<h2>\u306f\u3058\u3081<\/h2>\n<p>\u4eca\u56de\u306finnodb_thread_concurrency\u306b\u3064\u3044\u3066\u304a\u8a71\u3057\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002\u3067\u304d\u308c\u3070\u3001\u4e8b\u524d\u306b<a href=\"http:\/\/labs.gree.jp\/blog\/2015\/12\/15043\/\">InnoDB \u306e mutex \u306e\u8a71\uff08\u5165\u9580\u7de8\uff09<\/a>\u3092\u8aad\u3093\u3067\u3044\u305f\u3060\u3044\u305f\u65b9\u304c\u3001\u3088\u308a\u6df1\u304f\u7406\u89e3\u3057\u3066\u3044\u305f\u3060\u3051\u308b\u306e\u3067\u306f\u306a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u9577\u3044\u306e\u3067\u3001\u6700\u521d\u306b\u4e94\u884c\u3067\u307e\u3068\u3081\u307e\u3059<\/p>\n<ul>\n<li>\u73fe\u4ee3\u306b\u304a\u3044\u3066\u3001\u307b\u3068\u3093\u3069\u306e\u30b1\u30fc\u30b9\u3067\u306f\u3001innodb_thread_concurrency\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u306e0\u306e\u307e\u307e\u3067\u554f\u984c\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u3002\u306a\u305c\u306a\u3089\u3001\u6700\u8fd1\u306eInnoDB\u306f\u304b\u306a\u308a\u826f\u304f\u306a\u3063\u3066\u304d\u305f\u304b\u3089\u3067\u3059\u3002<\/li>\n<li>\u305d\u308c\u3067\u3082innodb_thread_concurrency\u3092\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u3059\u308b\u3068\u3057\u305f\u3089\u3001\u300c\u9ad8\u8ca0\u8377\u72b6\u614b\u306b\u306a\u3063\u305f\u3068\u304d\u3067\u3082\u30b9\u30ec\u30c3\u30c9\u9593\u306e\u516c\u5e73\u6027\u3092\u306a\u308b\u3079\u304f\u62c5\u4fdd\u3057\u3001\u5b89\u5b9a\u7a3c\u50cd\u3055\u305b\u308b\u305f\u3081\u300d\u3068\u5272\u308a\u5207\u3063\u3066\u4f7f\u3046\u306e\u304c\u826f\u3044\u3067\u3057\u3087\u3046\u3002<\/li>\n<li>innodb_thread_concurrency\u3092\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u3059\u308b\u306a\u3089\u3001 innodb_adaptive_max_sleep_delay\u304c\u3042\u308bMySQL\u3092\u4f7f\u3044\u307e\u3057\u3087\u3046\u3002<\/li>\n<li>innodb_concurrency_tickets\u3084innodb_commit_concurrency\u306f\u3001\u3044\u3063\u305f\u3093\u5fd8\u308c\u3066\u3082\u3088\u3044\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/li>\n<li>innodb_thread_concurrency\u3092\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u3057\u306a\u304f\u3066\u3082\u3001MySQL8.0\u306fInnoDB\u306e\u30ed\u30c3\u30af\u5468\u308a\u306b\u5927\u304d\u306a\u6539\u5584\u304c\u5165\u3063\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<\/li>\n<\/ul>\n<p>\u3067\u306f\u3001\u3042\u3093\u307e\u308a\u6614\u306e\u8a71\u3059\u308b\u306e\u3082\u6c17\u304c\u5f15\u3051\u307e\u3059\u304c\u3001\u904e\u53bb\u306e\u6b74\u53f2\u3092\u5c11\u3057\u632f\u308a\u8fd4\u308a\u3064\u3064\u3001\u73fe\u4ee3\u306b\u304a\u3044\u3066innodb_thread_concurrency\u3092\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u3057\u3066\u5b09\u3057\u3044\u306e\u306f\u3069\u306e\u3088\u3046\u306a\u30b1\u30fc\u30b9\u306a\u306e\u304b\u3001\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>\u592a\u53e4\u306einnodb_thread_concurrency<\/h2>\n<p>\u79c1\u304c innodb_thread_concurrency \u3092\u610f\u8b58\u3057\u59cb\u3081\u305f\u306e\u306f\u3001\u78ba\u304b2010\u5e74\u3042\u305f\u308aMySQL5.5\u304c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u308b\u524d\u5f8c\u304f\u3089\u3044\u3001\u307e\u3060\u307e\u3060 MySQL5.1 \u3068 InnoDB Plugin \u306e\u6642\u4ee3\u3067\u3057\u305f\u3002<\/p>\n<p>\u3058\u3064\u306finnodb_thread_concurrency\u3001\u304b\u306a\u308a\u6b74\u53f2\u306e\u53e4\u3044\u30d1\u30e9\u30e1\u30fc\u30bf\u3067\u3001 3.23.44\u30844.0.1\u306e\u9803\u306b\u306f\u3059\u3067\u306b\u5b58\u5728\u3057\u3066\u3044\u305f\u3088\u3046\u3067\u3059\u3002<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/innodb-performance-thread_concurrency.html\">\u592a\u53e4\u306e\u6614\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306f8<\/a>\u3060\u3063\u305f\u306e\u3067\u3059\u304c\u3001MySQL5.5\u304b\u30890\u304c\u30c7\u30d5\u30a9\u30eb\u30c8\u306b\u306a\u308a\u307e\u3057\u305f\u3002<br \/>\nMySQL5.5\u306e\u3068\u304d\u3001InnoDB Plugin\u304cInnoDB\u672c\u4f53\u306bmerge\u3055\u308c\u308b\u306a\u3069\u3057\u3066CPU\u30b9\u30b1\u30fc\u30e9\u30d3\u30ea\u30c6\u30a3\u304c\u6539\u5584\u3057\u305f==CPU\u306eCore\u305f\u304f\u3055\u3093\u3042\u3063\u3066\u3082\u3060\u3044\u3076\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3001\u3068\u3044\u3046\u3053\u3068\u304c\u3042\u308a\u307e\u3057\u305f\u3002\u9006\u306b\u3044\u3046\u3068\u3001\u306f\u308b\u304b\u3080\u304b\u3057\u306eInnoDB\u306fCore\u304c\u305f\u304f\u3055\u3093\u3042\u3063\u3066\u3082\u3042\u307e\u308a\u4f7f\u3048\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306einnodb_thread_concurrency=8\u306f\u300c\u305d\u3093\u306a\u306b\u305f\u304f\u3055\u3093\u306eCore\u4f7f\u3048\u306a\u3044\u3093\u3060\u304b\u3089\u3001\u540c\u6642\u5b9f\u884c\u30b9\u30ec\u30c3\u30c9\u6570\u306b\u306f\u30ad\u30e3\u30c3\u30d7\u304b\u3051\u305f\u65b9\u304c\u3044\u3044\u3088\u306d\u300d\u3068\u3044\u3046\u610f\u5473\u5408\u3044\u3060\u3063\u305f\u3068\u8a8d\u8b58\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u3053\u306e\u3068\u3053\u308d\u3069\u3046\u306a\u306e\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>sh2\u3055\u3093\u306eblog\u304b\u3089\u3001\u5f53\u6642\u306e\u72b6\u6cc1\u3092\u7aba\u3044\u77e5\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<ul>\n<li><a href=\"http:\/\/d.hatena.ne.jp\/sh2\/20100427\">2010-04-27 MySQL 5.1.46\u30ea\u30ea\u30fc\u30b9 InnoDB Plugin\u304c\u6b63\u5f0f\u7248\u306b<\/a><\/li>\n<\/ul>\n<p>\u3053\u308c\u304c\u306a\u304b\u306a\u304b\u885d\u6483\u7684\u306a\u304a\u8a71\u3067\u30012010\u5e74\u3042\u305f\u308a\u306f\u3001InnoDB Plugin \uff08\u3042\u308b\u3044\u306f\u3053\u306e\u5e74\u306bGA\u304c\u51fa\u305fMySQL5.5\uff09\u3092\u4f7f\u308f\u306a\u3044\u9650\u308a\u3001CPU\u306eCore\u6570\u304c16\u3092\u8d85\u3048\u308b\u3068\u30018Core\u306e\u30b5\u30fc\u30d0\u3088\u308a\u6027\u80fd\u304c\u51fa\u306a\u304f\u306a\u3063\u3066\u3044\u305f\u306e\u3067\u3059\u3002\u5f53\u7136\u3001\u6700\u8fd1\u306eMySQL\u306f\u3001\u306f\u308b\u304b\u306b\u305f\u304f\u3055\u3093\u306eCore\u3092\u3046\u307e\u304f\u6271\u3048\u308b\u306e\u3067\u3059\u304c\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u3001innodb_thread_concurrency \u306e\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u306f\u96e3\u3057\u3044\u3068\u3044\u3046\u3053\u3068\u3082\u3042\u3063\u3066\u3001Facebook \u306f InnoDB \u306e\u30b9\u30ec\u30c3\u30c9\u30b9\u30b1\u30b8\u30e5\u30fc\u30ea\u30f3\u30b0\u3092\u72ec\u81ea\u306e\u30d1\u30c3\u30c1\u3067\u884c\u3063\u3066\u3044\u308b\u307f\u305f\u3044\u3067\u3059\u306d\u3002\u8208\u5473\u306e\u3042\u308b\u65b9\u306f\u6b21\u306e\u8a18\u4e8b\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<ul>\n<li><a href=\"https:\/\/www.facebook.com\/notes\/mysql-at-facebook\/flifo-scheduling-for-innodb\/175800920932\/\">FLIFO scheduling for InnoDB<\/a><\/li>\n<\/ul>\n<p>\u3053\u306e\u3042\u305f\u308a\u3001\u5f53\u6642\u3092\u77e5\u308b\u6709\u8b58\u8005\u304b\u3089\u306e\u3054\u610f\u898b\u3054\u611f\u60f3\u3092\u304a\u5f85\u3061\u3057\u3066\u304a\u308a\u307e\u3059\u3002\u3061\u3087\u3046\u3069\u3053\u306e\u9803\u306bInnoDB\u306e\u6027\u80fd\u6539\u5584\u30d1\u30c3\u30c1\u3092\u66f8\u3044\u3066\u3044\u305f\u65b9\u306b\u3053\u3093\u3069\u304a\u4f1a\u3044\u3057\u305f\u3089\u3001\u3044\u308d\u3044\u308d\u304a\u8a71\u3092\u4f3a\u3063\u3066\u307f\u305f\u3044\u3068\u3053\u308d\u3067\u3059\u3002<\/p>\n<h2>MySQL5.5\u3068innodb_thread_concurrency<\/h2>\n<p>\u5f0a\u793e\u3067\u306f\u3001GA\u304c\u51fa\u3066\u534a\u5e74\u7acb\u305f\u306a\u3044\u3046\u3061\u306b\u3001MySQL5.5\u3092\u30d7\u30ed\u30c0\u30af\u30b7\u30e7\u30f3\u74b0\u5883\u3067\u4f7f\u3044\u59cb\u3081\u3066\u3044\u307e\u3057\u305f\u3002\u5f53\u6642\u3001\u79c1\u306f\u300c\u3044\u307e\u306fdisk I\/O\u306b\u5f8b\u901f\u3055\u308c\u308b\u90e8\u5206\u304c\u591a\u3044\u3051\u3069\u3001\u3053\u308c\u304b\u3089MySQL\u306f\u3001CPU\u3068\u30e1\u30e2\u30ea\u3068\u30ed\u30c3\u30af\u304c\u554f\u984c\u306b\u306a\u3063\u3066\u3044\u304f\u3093\u3060\u308d\u3046\u306a\u3041\u300d\u3068\u307c\u3093\u3084\u308a\u601d\u3063\u3066\u307e\u3057\u305f\u3002\u5b9f\u969b\u3001\u4f55\u5ea6\u304b innodb_thread_concurrency \u3092 0 \u4ee5\u5916\u306e\u5024\u306b\u5909\u66f4\u3057\u305f\u3044\u306a\u3041\u3068\u601d\u3063\u305f\u3053\u3068\u304c\u3042\u308a\u307e\u3057\u305f\u3002\u3057\u304b\u3057\u3001\u5f53\u6642\u306f\u300c\u307e\u3060\u3053\u3053\u306f\u3044\u3058\u308b\u3079\u304d\u3067\u306f\u306a\u3044\u300d\u3068\u898b\u9001\u3063\u3066\u307e\u3057\u305f\u3002<\/p>\n<p>\u306a\u305c\u304b\u3068\u8a00\u3044\u307e\u3059\u3068\u3001 MySQL5.5\u3067innodb_thread_concurrency\u3092\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u3059\u308b\u306e\u3067\u3042\u308c\u3070\u3001innodb_thread_sleep_delay\u3082\u8abf\u6574\u3059\u308b\u306e\u304c\u826f\u304b\u3063\u305f\u306e\u3067\u3059\u304c\u3001innodb_thread_sleep_delay\u306e\u6700\u9069\u5024\u306f\u30ef\u30fc\u30af\u30ed\u30fc\u30c9\u306b\u3088\u3063\u3066\u7570\u306a\u308b\u3082\u306e\u3067\u3042\u308a\u3001\u6c4e\u7528\u7684\u306a\u8a2d\u5b9a\u3068\u3044\u3046\u306e\u304c\u304b\u306a\u308a\u96e3\u3057\u304b\u3063\u305f\u308f\u3051\u3067\u3059\u3002\u3042\u307e\u308a\u9ed2\u9b54\u8853\u7684\u306a\u8a2d\u5b9a\u3092\u5165\u308c\u308b\u3068\u3001\u5c06\u6765\u3001MySQL\u306e\u30e1\u30b8\u30e3\u30fc\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u4e0a\u3052\u305f\u304f\u306a\u3063\u305f\u3068\u304d\u306b\u691c\u8a3c\u304c\u7169\u96d1\u306b\u306a\u308b\u306e\u3067\u3001\u3053\u306e\u3053\u308d\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5074\u3067SQL\u76f4\u305b\u308b\u306a\u3089\u76f4\u3057\u3066\u3082\u3089\u3063\u305f\u308a\u3001sharding\u3059\u308b\u306a\u3069\u3057\u3066\u5bfe\u5fdc\u3057\u3066\u3082\u3089\u3063\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>MySQL5.5\u3067\u306finnodb_thread_concurrency\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u304c0\u306b\u306a\u3063\u305f\u3060\u3051\u3042\u3063\u3066\u3001\u304b\u306a\u308a\u306e\u30b1\u30fc\u30b9\u3067InnoDB\u306fCPU\u306eCore\u3092\u3046\u307e\u304f\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3057\u305f\u3002\u307e\u305f\u3001InnoDB Plugin\u304cInnoDB\u672c\u4f53\u306bmerge\u3055\u308c\u305f\u3053\u3068\u306b\u3088\u308a\u3001\u521d\u671f\u306eInnoDB Adaptive Flushing\u304c\u5c0e\u5165\u3055\u308c\u305f\u3053\u3068\u3082\u3042\u308a\u3001\u4ee5\u524d\u3068\u6bd4\u3079\u308b\u3068\u3060\u3044\u3076InnoDB\u306f\u6539\u5584\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u3002\u3044\u307e\u601d\u3048\u3070\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5074\u3067SQL\u306a\u3069\u4fee\u6b63\u3057\u3066\u3082\u3089\u3046\u3053\u3068\u306f\u3001\u3080\u304b\u3057\u306b\u6bd4\u3079\u308b\u3068\u3060\u3044\u3076\u9650\u5b9a\u7684\u306b\u306a\u3063\u3066\u3044\u305f\u306e\u3067\u306f\u306a\u3044\u304b\u306a\u3041\u3068\u3044\u3046\u6c17\u304c\u3057\u307e\u3059\u3002<\/p>\n<h2>MySQL5.6\u3068innodb_thread_concurrency<\/h2>\n<p>\u3053\u306e\u9803\u306b\u306a\u308b\u3068\u3001\u3044\u308d\u3044\u308d\u3068\u72b6\u6cc1\u304c\u5909\u308f\u3063\u3066\u304d\u307e\u3057\u305f\u3002\u4ee5\u524d\u3068\u6bd4\u3079\u3066\u4f55\u304c\u5909\u308f\u3063\u3066\u6765\u305f\u304b\u3068\u3044\u3046\u3068\u3001\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u306e\u9032\u5316\u304c\u7121\u8996\u3067\u304d\u306a\u3044\u30ec\u30d9\u30eb\u306b\u306a\u3063\u3066\u304d\u307e\u3057\u305f\u3002\u5177\u4f53\u7684\u306b\u5217\u6319\u3057\u307e\u3059\u3068\u3001\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<ul>\n<li>CPU\u306eCore\u6570\u304c\u5897\u3048\u3066\u304d\u305f\u306e\u3067\u3001\uff08\u4eee\u60f3\u5316\u3057\u306a\u3044\u306e\u3067\u3042\u308c\u3070\uff09\u7d30\u304b\u304fsharding\u3057\u3066\u3044\u304f\u3088\u308a\u3001\u3042\u308b\u7a0b\u5ea6\u5927\u304d\u3044DB\u3092\u6271\u3046\u3088\u3046\u306b\u3057\u305f\u307b\u3046\u304c\u30b3\u30b9\u30c8\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u826f\u3044<\/li>\n<li>NAND Flash\u306e\u4fa1\u683c\u304c\u304b\u306a\u308a\u4e0b\u304c\u3063\u3066\u304d\u305f\u306e\u3067\u3001\u5927\u5bb9\u91cf\u306eSSD\u3092\u5c0e\u5165\u3057\u3084\u3059\u304f\u306a\u3063\u3066\u304d\u305f\u3002\u304b\u3064\u3066\u306f\u7d30\u304b\u304fsharding\u3057\u3066\u3044\u305fDB\u3082\u3001\u5927\u5bb9\u91cf\u306eSSD\u3067\u7d71\u5408\u3057\u3066\u3044\u3063\u305f\u65b9\u304c\u3001\u30b3\u30b9\u30c8\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u826f\u304f\u306a\u308b<\/li>\n<li>SSD\u306e\u6027\u80fd\u304c\u826f\u304f\u306a\u3063\u3066\u304d\u305f\uff06\u5927\u5bb9\u91cf\u306e\u30e1\u30e2\u30ea\u3092\u7a4d\u3080\u3053\u3068\u3082\u96e3\u3057\u304f\u306a\u304f\u306a\u3063\u3066\u304d\u305f<\/li>\n<\/ul>\n<p>\u307e\u305f\u3001MySQL5.6\u304b\u3089InnoDB Adaptive Flushing\u306e\u6319\u52d5\u306a\u3069\u5909\u308f\u3063\u305f\u305f\u3081\u3001 I\/O \u5468\u308a\u306e\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u304c5.5\u4ee5\u524d\u3088\u308a\u5bb9\u6613\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u305d\u306e\u7d50\u679c\u3001\u61f8\u5ff5\u3057\u3066\u3044\u305f\u3068\u304a\u308a\u3001MySQL\u306e\u554f\u984c\u306f\u3001CPU\u3068\u30e1\u30e2\u30ea\u3001\u30ed\u30c3\u30af\u306e\u554f\u984c\u3078\u3068\u3001\u63a8\u79fb\u3057\u3066\u304d\u305f\u308f\u3051\u3067\u3059\u3002\uff08\u3042\u304f\u307e\u3067\u3082\u500b\u4eba\u7684\u306a\u611f\u60f3\u3067\u3059\u304c\uff09<\/p>\n<p>\u3053\u306e\u9803\u306b\u306a\u308b\u3068\u300cInnoDB Adaptive Flushing\u306e\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u3082\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u304d\u305f\u3057\u3001\u5927\u5bb9\u91cf\u306eSSD\u5c0e\u5165\u3057\u3084\u3059\u304f\u306a\u3063\u3066\u304d\u305f\u3057\u3001innodb_thread_concurrency\u306e\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u3057\u305f\u65b9\u304c\u826f\u3044\u304b\u3082\u300d\u3068\u601d\u3046\u3088\u3046\u306b\u306a\u308a\u3001\u5f0a\u793e\u306e\u5927\u90e8\u5206\u306emysqld\u3067\u306f\u3001innodb_thread_concurrency\u3092\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u5f0a\u793e\u3067\u306f\u3001MySQL5.0\u30845.1\u306e\u6642\u4ee3\u3001InnoDB Plugin \u4ee5\u524d\u306e\u6642\u4ee3\u304b\u3089\u591a\u7a2e\u591a\u69d8\u306ametric\u3092\u53d6\u5f97\u3057\u7d9a\u3051\u3066\u3001\u6f38\u304f\u300c\u305d\u308d\u305d\u308d\u30b3\u30b3\u306b\u3082\u3001innodb_thread_concurrency\u306b\u3082\u7740\u624b\u3059\u308b\u304b\u300d\u3068\u3044\u3046\u8e0f\u3093\u5207\u308a\u304c\u3064\u3044\u305f\u308f\u3051\u3067\u3059\u3002<\/p>\n<h2>\u3067\u306f\u3001MySQL5.7\u3067innodb_thread_concurrency\u306f\u3069\u306e\u3088\u3046\u306b\u6a5f\u80fd\u3059\u308b\u306e\u304b<\/h2>\n<p>\u30b3\u30fc\u30c9\u3092\u8aad\u3093\u3060\u65b9\u304c\u65e9\u3044\u3068\u601d\u3046\u306e\u3067\u3001\u8a66\u3057\u306bMySQL5.7\u306b\u304a\u3051\u308bDELETE\u306e\u5b9f\u88c5\u3092\u8aad\u3093\u3067\u3044\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/mysql\/mysql-server\/blob\/7cfee48560e1b08384da3a1e245d5b125e2ef36b\/sql\/sql_delete.cc#L48\">Sql_cmd_delete::mysql_delete()<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/mysql\/mysql-server\/blob\/7cfee48560e1b08384da3a1e245d5b125e2ef36b\/sql\/sql_delete.cc#L468\">sql\/sql_delete.cc#L468<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/mysql\/mysql-server\/blob\/7cfee48560e1b08384da3a1e245d5b125e2ef36b\/sql\/handler.cc#L7941\">handler::ha_delete_row()<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/mysql\/mysql-server\/blob\/7cfee48560e1b08384da3a1e245d5b125e2ef36b\/sql\/handler.cc#L7964\">sql\/handler.cc#L7946<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/mysql\/mysql-server\/blob\/7cfee48560e1b08384da3a1e245d5b125e2ef36b\/storage\/innobase\/handler\/ha_innodb.cc#L8204\">ha_innobase::delete_row()<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/github.com\/mysql\/mysql-server\/blob\/7cfee48560e1b08384da3a1e245d5b125e2ef36b\/storage\/innobase\/handler\/ha_innodb.cc#L8242-L8246\">storage\/innobase\/handler\/ha_innodb.cc#L8242-L8246<\/a><\/p>\n<pre><code class=\"language-c\">    innobase_srv_conc_enter_innodb(m_prebuilt);\n\n    error = row_update_for_mysql((byte*) record, m_prebuilt);\n\n    innobase_srv_conc_exit_innodb(m_prebuilt);\n<\/code><\/pre>\n<p>\uff08\u305f\u3044\u3078\u3093\u3056\u3063\u304f\u308a\u8a00\u3044\u307e\u3059\u3068\uff09InnoDB\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u30ec\u30b3\u30fc\u30c9\u3092\u66f4\u65b0\uff08\u524a\u9664\uff09\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u308b\u524d\u5f8c\u304c innobase_srv_conc_enter_innodb() \u3068 innobase_srv_conc_exit_innodb() \u3067\u30ac\u30fc\u30c9\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u306e\u4e2d\u3067 innodb_thread_concurrency\uff08\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e2d\u3067\u306fsrv_thread_concurrency\uff09\u304c\u53c2\u7167\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/mysql\/mysql-server\/blob\/7cfee48560e1b08384da3a1e245d5b125e2ef36b\/storage\/innobase\/handler\/ha_innodb.cc#L1474\">innobase_srv_conc_enter_innodb()<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/github.com\/mysql\/mysql-server\/blob\/7cfee48560e1b08384da3a1e245d5b125e2ef36b\/storage\/innobase\/handler\/ha_innodb.cc#L1485-L1486\">storage\/innobase\/handler\/ha_innodb.cc#L1485-L1486<\/a><\/p>\n<pre class=\"lang:default decode:true \" >\n    if (srv_thread_concurrency) {\n        if (trx-&gt;n_tickets_to_enter_innodb &gt; 0) {\n<\/pre>\n<p>n_tickets_to_enter_innodb \u304c\u3044\u308f\u3086\u308b innodb_concurrency_tickets \u306a\u306e\u3067\u3059\u304c\u3001\u3053\u3053\u306f\u8efd\u304f\u6d41\u3057\u307e\u3059\u3002\uff08\u3042\u3068\u3067\u307e\u305f\u632f\u308a\u8fd4\u308a\u307e\u3059\u3002\uff09<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/mysql\/mysql-server\/blob\/7cfee48560e1b08384da3a1e245d5b125e2ef36b\/storage\/innobase\/handler\/ha_innodb.cc#L1502\">storage\/innobase\/handler\/ha_innodb.cc#L1502<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/mysql\/mysql-server\/blob\/7cfee48560e1b08384da3a1e245d5b125e2ef36b\/storage\/innobase\/srv\/srv0conc.cc#L244\">srv_conc_enter_innodb()<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/mysql\/mysql-server\/blob\/7cfee48560e1b08384da3a1e245d5b125e2ef36b\/storage\/innobase\/srv\/srv0conc.cc#L257\">storage\/innobase\/srv\/srv0conc.cc#L257<\/a><\/li>\n<\/ul>\n<p>\u3053\u3053\u3067\u547c\u3070\u308c\u3066\u3044\u308b <a href=\"https:\/\/github.com\/mysql\/mysql-server\/blob\/7cfee48560e1b08384da3a1e245d5b125e2ef36b\/storage\/innobase\/srv\/srv0conc.cc#L102-L223\">srv_conc_enter_innodb_with_atomics()<\/a> \u304c\u672c\u4e38\u3067\u3059\u3002<\/p>\n<h4>srv_conc_enter_innodb_with_atomics()<\/h4>\n<p>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3068\u305d\u306e\u30b3\u30e1\u30f3\u30c8\u3092\u8aad\u3093\u3067\u3082\u3089\u3048\u308c\u3070\u305d\u306e\u901a\u308a\u306a\u306e\u3067\u3059\u304c\u3001\u3053\u306e\u95a2\u6570\u306f\u3001InnoDB\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3088\u3046\u3068\u3059\u308b\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30b9\u30ec\u30c3\u30c9\u304cinnodb_thread_concurrency\u3092\u8d85\u3048\u3066\u3044\u308b\u9650\u308a\u3001\u30eb\u30fc\u30d7\u3057\u3066sleep\u3092\u7e70\u308a\u8fd4\u3057\u307e\u3059\u3002<br \/>\n\u56db\u884c\u3067\u3056\u3063\u304f\u308a\u307e\u3068\u3081\u308b\u3068<\/p>\n<ol>\n<li>InnoDB \u306b\u30a2\u30af\u30bb\u30b9\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u308b\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30b9\u30ec\u30c3\u30c9\u304csrv_thread_concurrency\uff08innodb_thread_concurrency\uff09\u3092\u8d85\u3048\u3066\u3044\u305f\u5834\u5408\u3001srv_thread_sleep_delay(innodb_thread_sleep_delay)\u3060\u3051sleep\u3057\u307e\u3059\u3002<\/li>\n<li>srv_adaptive_max_sleep_delay(innodb_adaptive_max_sleep_delay)\u304c0\u3088\u308a\u5927\u304d\u304f\u3001\u304b\u3064\u3001sleep\u306e\u30eb\u30fc\u30d7\u304c\u4e8c\u5468\u76ee\u4ee5\u964d\u3060\u3063\u305f\u5834\u5408\u3001srv_thread_sleep_delay\u3092\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u3057\u307e\u3059\uff08\u4e00\u5468\u76ee\u306f\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u3057\u306a\u3044\u308f\u3051\u3067\u3059\u306d\u3002\u7e70\u308a\u8fd4\u3057sleep\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3088\u3046\u306a\u5fd9\u3057\u304f\u72b6\u6cc1\u3067\u3042\u308c\u3070\u3001sleep\u3059\u308b\u6642\u9593\u3092\u9577\u304f\u3059\u308b\u308f\u3051\u3067\u3059\uff09\u3002<\/li>\n<li>\u30eb\u30fc\u30d7\u306e\u5148\u982d\u306b\u623b\u3063\u3066\u3001InnoDB \u306b\u30a2\u30af\u30bb\u30b9\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u308b\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30b9\u30ec\u30c3\u30c9\u306e\u6570\u3092\u518d\u5ea6\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/li>\n<li>InnoDB \u306b\u30a2\u30af\u30bb\u30b9\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u308b\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30b9\u30ec\u30c3\u30c9\u304csrv_thread_concurrency\u3088\u308a\u5c11\u306a\u3051\u308c\u3070\u3001srv_thread_sleep_delay\u3092\u6e1b\u3089\u3057\u3066\u30eb\u30fc\u30d7\u3092\u629c\u3051\u307e\u3059\u3002\u591a\u3051\u308c\u3070 2.\u304b\u3089\u3084\u308a\u76f4\u3057\u307e\u3059\u3002<\/li>\n<\/ol>\n<p>\u3068\u3044\u3046\u308f\u3051\u3067\u3001\u5148\u306bInnoDB\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3088\u3046\u3068\u3057\u305f\u30b9\u30ec\u30c3\u30c9\u307b\u3069sleep\u304c\u77ed\u304f\u3001\u5f8c\u304b\u3089\u30a2\u30af\u30bb\u30b9\u3057\u3088\u3046\u3068\u3057\u305f\u30b9\u30ec\u30c3\u30c9\u307b\u3069sleep\u304c\u9577\u304f\u306a\u308b\u306e\u3067\u3001\u6319\u52d5\u3068\u3057\u3066\u306fFIFO\u306e\u30ad\u30e5\u30fc\u3063\u307d\u3044\u3082\u306e\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u3001\u5192\u982d\u3067\u89e6\u308c\u305f<a href=\"http:\/\/labs.gree.jp\/blog\/2015\/12\/15043\/\">InnoDB \u306e mutex \u306e\u8a71\uff08\u5165\u9580\u7de8\uff09<\/a>\u306e\u8a71\u306b\u623b\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>InnoDB \u306e mutex \u5468\u308a\u306e\u5b9f\u88c5\u306f\u3001spin loop(spinlock)\u3068mutex\u306e\u4e8c\u6bb5\u69cb\u3048\u306a\u308f\u3051\u3067\u3059\u304c\u3001\u3042\u307e\u308a\u306b\u3082\u5927\u91cf\u306e\u30b9\u30ec\u30c3\u30c9\u304c\u540c\u6642\u306b\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u3068\u3001spinlock\u306fCPU\u3092\u7121\u99c4\u9063\u3044\u3057\u3066\u3057\u307e\u3046\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002innodb_thread_concurrency=0\u3067sysbench\u306a\u3069\u5b9f\u884c\u3057\u3064\u3064<\/p>\n<pre><code class=\"language-bash\">$ sudo perf top\n<\/code><\/pre>\n<p>\u306a\u3069\u3067\u78ba\u8a8d\u3057\u3066\u3044\u305f\u3060\u304f\u3068\u3001mysqld\u306eut_delay()\u304cCPU\u3092\u304b\u306a\u308a\u4f7f\u3063\u3066\u308b\u5834\u5408\u304c\u3042\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002\u3053\u308c\u306f\u3064\u307e\u308a\u3001ut_delay()==spinlock\u3067CPU\u3092\u4f7f\u3063\u3066\u3044\u308b\u3001\u4e00\u53f0\u306eDB\u3067\u5927\u91cf\u306e\u30b9\u30ec\u30c3\u30c9\u3092\u5b9f\u884c\u3055\u305b\u3088\u3046\u3068\u3059\u308b\u3068\u3001\u30b9\u30ec\u30c3\u30c9\u9593\u306e\u8abf\u505c\u306e\u305f\u3081\u306bCPU\u30ea\u30bd\u30fc\u30b9\u3092\u5c11\u306a\u304b\u3089\u305a\u6301\u3063\u3066\u3044\u304b\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u3068\u3044\u3046\u3053\u3068\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306f\u3044\u304b\u306b\u3082\u3082\u3063\u305f\u3044\u306a\u3044\u3067\u3059\u306d\u3002\u307e\u305f\u3001\u5927\u91cf\u306e\u30b9\u30ec\u30c3\u30c9\u304c\u540c\u6642\u306b\u5b9f\u884c\u3055\u308c\u3066 OS Waits \u304c\u5927\u91cf\u306b\u5897\u3048\u3066\u3044\u308b\u3068\u304d\u3001 Thundering herd problem \u304c\u5f15\u304d\u8d77\u3053\u3055\u308c\u308b\u53ef\u80fd\u6027\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u3088\u3046\u306a\u72b6\u6cc1\u306b\u306a\u3063\u3066\u3044\u308b\u3068\u304d\u3001innodb_thread_concurrency\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u4f55\u304c\u671f\u5f85\u3067\u304d\u308b\u304b\u3068\u3044\u3046\u3068\u3001<\/p>\n<ul>\n<li>InnoDB\u306b\u540c\u6642\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u30b9\u30ec\u30c3\u30c9\u306e\u6570\u3092\u5236\u9650\u3059\u308b<\/li>\n<li>\u30a2\u30af\u30bb\u30b9\u3092\u5236\u9650\u3055\u308c\u3066\u3044\u308b\u30b9\u30ec\u30c3\u30c9\u306f\u3001\u5404\u81easleep\u3057\u3066\u5f85\u3063\u3066\u3044\u308b\u3002sleep\u3057\u3066\u3044\u308b\u306e\u3067\u7121\u99c4\u306a context switch \u306f\u6e1b\u3089\u305b\u308b\u3057\u3001 spin lock \u307b\u3069CPU\u30ea\u30bd\u30fc\u30b9\u3092\u6d88\u8cbb\u3057\u306a\u3044\u3002<\/li>\n<li>\u5f8c\u304b\u3089\u6765\u305f\u30b9\u30ec\u30c3\u30c9\u307b\u3069\u9577\u304fsleep\u3057\u3066\u5f85\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u5148\u306b\u6765\u305f\u30b9\u30ec\u30c3\u30c9\u307b\u3069\u3001\u5148\u306btransaction\u3092\u5b8c\u4e86\u3055\u305b\u3084\u3059\u3044\u3002\u3064\u307e\u308a\u3001\u30b9\u30ec\u30c3\u30c9\u9593\u306e\u516c\u5e73\u6027\u3092\u62c5\u4fdd\u3055\u305b\u3084\u3059\u304f\u306a\u308b\u3002<\/li>\n<\/ul>\n<p>\u3068\u3044\u3046\u308f\u3051\u3067\u3059\u3002<\/p>\n<h4>innodb_adaptive_max_sleep_delay<\/h4>\n<p>MySQL5.6.3\u304b\u3089innodb_adaptive_max_sleep_delay\u3068\u3044\u3046\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3057\u305f\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u306e150000\u306f\u3001innodb_thread_sleep_delay\u306f\u52d5\u7684\u306b150000\u307e\u3067\u5897\u3048\u3066\u826f\u3044\u3068\u3044\u3046\u610f\u306a\u306e\u3067\u3059\u304c\u3001innodb_thread_sleep_delay\u306e\u5358\u4f4d\u306fmicro seonds\u306a\u306e\u3067\u3001150000 micro seonds = 150msec = 0.15sec \u307e\u3067\u5897\u3048\u3066\u826f\u3044\u3001\u3068\u3044\u3046\u610f\u5473\u3067\u3059\u3002\u305f\u3060\u3001\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30b9\u30ec\u30c3\u30c9\u306e\u6570\u304cinnodb_thread_concurrency\u3088\u308a\u4f4e\u3044\u3068\u3001innodb_thread_sleep_delay\u306f\u30ac\u30f3\u30ac\u30f3\u4e0b\u304c\u308a\u307e\u3059\u30029\u3068\u304b19\u3068\u304b\u307e\u3067\u3001\u30db\u30f3\u30c8\u306b\u7af6\u5408\u3057\u306a\u3044\u306a\u30890\u307e\u3067\u4e0b\u304c\u308a\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001 MySQL5.7 \u3067 sysbench 1.10 \u306e oltp_read_write.lua \u3092\u5b9f\u884c\u3057\u305f\u3068\u304d\u3001innodb_thread_sleep_delay\u306f\u6b21\u306e\u3088\u3046\u306b\u3051\u3063\u3053\u3046\u6fc0\u3057\u304f\u5909\u52d5\u3057\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2018\/07\/5191297-cb9058ba584a7db9802faef23b1a32b3fb8b4ab7.png\" alt=\"\" \/><br \/>\n<img decoding=\"async\" src=\"http:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2018\/07\/5191299-5057749ab3c6a42990e93c5210508ebcbf96011f.png\" alt=\"\" \/><\/p>\n<p>\u305f\u3060\u3001\u5b9f\u969b\u3053\u308c\u3060\u3051\u7d30\u3084\u304b\u306b sleep \u3067\u304d\u308b\u304b\u306f\u307e\u305f\u5225\u306e\u8a71\u3067\u3059\u3002MySQL5.7\u3067\u306f\u3001innodb_thread_sleep_delay\u3067\u306esleep\u306f\u3001 nanosleep(2) \u306e\u3042\u308b\u74b0\u5883\u3067\u306f nanosleep \u3067sleep\u3059\u308b\u306e\u3067\u3001\u305d\u306e\u7cbe\u5ea6\u306f\u51e6\u7406\u7cfb\u306b\u4f9d\u5b58\u3057\u307e\u3059\u3002innodb_thread_sleep_delay=0\u306b\u306a\u3063\u305f\u3068\u304d\u306f\u3055\u3066\u304a\u304d\u3001\u5b9f\u969b\u306f 9 micro seconds \u3068\u304b 19 micro seconds \u3067\u306f\u306a\u304f\u3001sleep\u3059\u308b\u6642\u9593\u306e\u6700\u5c0f\u5024\u306fnanosleep\u306b\u4f9d\u5b58\u3057\u3001\u6700\u5927\u5024\u306finnodb_adaptive_max_sleep_delay\u6b21\u7b2c\u3001\u3068\u3044\u3063\u305f\u3068\u3053\u308d\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>MySQL5.5\u4ee5\u524d\u306finnodb_adaptive_max_sleep_delay\u3068\u3044\u3046\u6982\u5ff5\u304c\u306a\u304b\u3063\u305f\u305f\u3081\u3001innodb_thread_sleep_delay\u306f\u30b5\u30fc\u30d0\u306e\u8ca0\u8377\u306b\u5fdc\u3058\u3066\u5909\u52d5\u3059\u308b\u308f\u3051\u3067\u306f\u306a\u304f\u3001DBA\u306f\u81ea\u5206\u3067\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>OLTP\u306e\u3088\u3046\u306b\u4e00\u3064\u4e00\u3064\u306eSQL\u304c\u3054\u304f\u77ed\u6642\u9593\u3067\u7d42\u4e86\u3059\u308b\u306a\u3089\u3070\u3001innodb_thread_sleep_delay\u306f\u3042\u307e\u308a\u9577\u3059\u304e\u306a\u3044\u307b\u3046\u304c\u826f\u3044\u306e\u3067\u3059\u3002\u4f8b\u3048\u3070\u3001\u5f85\u3063\u3066\u308b\u30b9\u30ec\u30c3\u30c9\u304c\u9577\u6642\u9593sleep\u3057\u3066\u3044\u308b\u9593\u306b\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30b9\u30ec\u30c3\u30c9\u304c\u5c45\u306a\u304f\u306a\u3063\u305f\u5834\u5408\u3001\u305d\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u5f8c\u304b\u3089\u3084\u3063\u3066\u304d\u305f\u30b9\u30ec\u30c3\u30c9\u304c\u5148\u306b\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3067\u304d\u3066\u3057\u307e\u3046\u308f\u3051\u3067\u3001\u30b9\u30ec\u30c3\u30c9\u9593\u306e\u516c\u5e73\u6027\u3092\u4fdd\u3061\u306b\u304f\u304f\u306a\u308a\u307e\u3059\u3002<br \/>\n\u4e00\u65b9\u3001OLAP\u306e\u3088\u3046\u306b\u4e00\u3064\u4e00\u3064\u306eSQL\u306b\u6642\u9593\u304c\u304b\u304b\u308b\u306e\u3067\u3042\u308c\u3070\u3001innodb_thread_sleep_delay\u306f\u9069\u5ea6\u306b\u9577\u3044\u307b\u3046\u304c\u3001\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30b9\u30ec\u30c3\u30c9\u305f\u3061\u304c\u30ed\u30c3\u30af\u3092\u89e3\u9664\u3067\u304d\u308b\u307e\u3067\u5f85\u3066\u308b\u65b9\u304c\u826f\u3044\u308f\u3051\u3067\u3059\u3002<\/p>\n<p>\u30b2\u30fc\u30e0\u306e\u3088\u3046\u306b\u3001\u5f8c\u304b\u3089\u6a5f\u80fd\u3084\u30a4\u30d9\u30f3\u30c8\u304c\u8ffd\u52a0\u3055\u308c\u308b\u3088\u3046\u306a\u6027\u8cea\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f\u3001\u3059\u3079\u3066\u306emysqld\u3067\u9069\u5207\u306ainnodb_thread_sleep_delay\u3092\u6c42\u3081\u308b\u3053\u3068\u306f\u3001\u304b\u306a\u308a\u96e3\u3057\u3044\u308f\u3051\u3067\u3059\u3002\u79c1\u306fMySQL5.5\u3067\u306f\u305d\u3053\u306b\u61f8\u5ff5\u3092\u6301\u3063\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u30015.6\u3067innodb_adaptive_max_sleep_delay\u304c\u8ffd\u52a0\u3055\u308c\u305f\u3053\u3068\u306b\u3088\u308a\u3001\u305a\u3044\u3076\u3093\u697d\u306b\u306a\u3063\u305f\u306a\u3041\u3068\u611f\u3058\u5165\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u73fe\u4ee3\u306b\u304a\u3044\u3066innodb_thread_concurrency\u3092\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u3059\u308b\u76ee\u7684<\/h2>\n<p>\u6975\u3081\u3066\u500b\u4eba\u7684\u306a\u898b\u89e3\u3067\u3059\u304c\u3001\u4e00\u8a00\u3067\u8a00\u3046\u3068\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<ul>\n<li>mysqld \u304c\u9ad8\u8ca0\u8377\u72b6\u614b\u306b\u306a\u3063\u305f\u3068\u304d\u3067\u3082\u3001\u30b9\u30ec\u30c3\u30c9\u9593\u306e\u516c\u5e73\u6027\u3092\u306a\u308b\u3079\u304f\u62c5\u4fdd\u3057\u3064\u3064\u3001\u5b89\u5b9a\u3057\u305f respone \u3092\u8fd4\u305b\u308b\u3088\u3046\u306b\u3059\u308b\u3002<\/li>\n<\/ul>\n<p>capacity planning \u304c\u7406\u60f3\u7684\u306b\u3046\u307e\u304f\u884c\u304f\u306a\u3089\u3001 innodb_thread_concurrency=0 \u306e\u307e\u307e\u306b\u3057\u3066\u3001\u30b9\u30b1\u30fc\u30eb\u30a2\u30c3\u30d7\u3084\u30b9\u30b1\u30fc\u30eb\u30a2\u30a6\u30c8\u3092\u3057\u3066\u3001\u30b7\u30b9\u30c6\u30e0\u3092\u5897\u5f37\u3057\u3066\u3044\u3051\u3070\u826f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\u3057\u304b\u3057\u3001 sharding \u3084\u30b9\u30b1\u30fc\u30eb\u30a2\u30c3\u30d7\u304c\u9593\u306b\u5408\u308f\u306a\u3044\u3068\u3044\u3046\u4e8b\u614b\u3082\u3001\u60f3\u5b9a\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3068\u304d\u304c\u3042\u308a\u307e\u3059\u3002\u305d\u3046\u3044\u3063\u305f\u3068\u304d\u3001\uff08innodb_thread_sleep_delay\u306e\u5206\u3060\u3051nanosleep\u3059\u308b\u306e\u3067\u3001\u3054\u304f\u50c5\u304b\u3068\u306f\u3044\u3048\u5f85\u3063\u3066\u3044\u305f\u3060\u304f\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u304c\uff09\u5c11\u3057\u3067\u3082\u5b89\u5b9a\u3057\u3066 response \u3092\u8fd4\u305b\u308b\u3088\u3046\u3001\u306a\u3093\u3068\u304b\u52aa\u3081\u305f\u3044\u306e\u3067\u3059\u3002\u305d\u3046\u3044\u3063\u305f\u3068\u304d\u306e\u5099\u3048\u3068\u3057\u3066\u3001\u30bb\u30fc\u30d5\u30c6\u30a3\u3068\u3057\u3066innodb_thread_concurrency\u3092\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u3057\u3066\u304a\u304f\u3068\u3001innodb_thread_concurrency=0\u306e\u3068\u304d\u3088\u308a\u5b89\u5b9a\u3057\u3066response\u304c\u8fd4\u305b\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>mysqld\u304c\u9ad8\u8ca0\u8377\u72b6\u614b\u306b\u306a\u308b\u8981\u56e0\u3067\u3059\u304c\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d0\u306brequest\u304c\u305f\u304f\u3055\u3093\u6765\u305f\u3068\u304b\u3001\u30b2\u30fc\u30e0\u3067\u65b0\u3057\u3044\u30a4\u30d9\u30f3\u30c8\u304c\u59cb\u307e\u3063\u305f\u3068\u304b\u3001\u65b0\u3057\u3044\u30b5\u30fc\u30d3\u30b9\u304c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u305f\u3068\u304b\u3001\u305d\u3046\u3044\u3063\u305f\u3082\u306e\u3060\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u5927\u5bb9\u91cf\u306eSSD\u306bDB\u3092\u96c6\u7d04\u3057\u3066\u3044\u304f\u3068\u3001\u4e00\u53f0\u306e\u30b5\u30fc\u30d0\u306ehostdown\u304c\u4e0e\u3048\u308b\u5f71\u97ff\u3084\u3001\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u6545\u969c\u306e\u5f71\u97ff\u304c\u5927\u304d\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3088\u308a\u5b89\u5168\u306b\u30b5\u30fc\u30d0\u3092\u96c6\u7d04\u3057\u3066\u3044\u304f\u305f\u3081\u306b\u306f\u3001\u9ad8\u8ca0\u8377\u72b6\u614b\u306b\u306a\u3063\u305f\u3068\u304d\u3067\u3082\u5b89\u5b9a\u7a3c\u50cd\u3067\u304d\u308b\u3088\u3046\u306a\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u304c\u6c42\u3081\u3089\u308c\u308b\u308f\u3051\u306a\u306e\u3067\u3059\u3002<\/p>\n<h2>innodb_thread_concurrency\u3092\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u3059\u308b\u969b\u306e\u30dd\u30a4\u30f3\u30c8<\/h2>\n<p>\u3067\u306f\u3001\u305d\u3046\u3044\u3063\u305f\u3053\u3068\u3092\u8e0f\u307e\u3048\u3066\u3001\u6562\u3048\u3066innodb_thread_concurrency\u3092\u30c7\u30d5\u30a9\u30eb\u30c8\u4ee5\u5916\u306e\u5024\u306b\u3057\u305f\u3044\u3068\u8003\u3048\u305f\u3068\u304d\u3001\u3069\u308c\u304f\u3089\u3044\u306e\u5024\u304c\u9069\u5207\u3068\u8a00\u3048\u308b\u3067\u3057\u3087\u3046\u304b\u3002\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u5185\u306e<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.6\/ja\/innodb-parameters.html#sysvar_innodb_thread_concurrency\">innodb_thread_concurrency<\/a>\u306b\u95a2\u3059\u308b\u8a18\u8ff0\u306f\u3001\u3042\u306a\u304c\u3061\u9593\u9055\u3044\u3067\u3082\u306a\u3044\u3068\u601d\u308f\u308c\u307e\u3059\u3002\u3068\u3044\u3046\u304b\u3053\u306e\u3042\u305f\u308a\u3001\u4f7f\u3063\u3066\u3044\u308b\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u3084MySQL\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3001\u30ef\u30fc\u30af\u30ed\u30fc\u30c9\u306b\u3088\u3063\u3066\u5343\u5909\u4e07\u5316\u3059\u308b\u3068\u3053\u308d\u306a\u306e\u3067\u3001\u4e00\u6982\u306b\u30b3\u30ec\u3068\u3044\u3046\u6700\u9069\u89e3\u306f\u306a\u3044\u3088\u3046\u306b\u601d\u308f\u308c\u307e\u3059\u3002<\/p>\n<p>innodb_thread_concurrency \u306f SET GLOBAL \u3067\u52d5\u7684\u306b\u5909\u66f4\u3067\u304d\u308b\u306e\u3067\u3001\u5909\u3048\u305f\u304f\u306a\u3063\u305f\u3089\u90fd\u5ea6\u5909\u3048\u3066\u3082\u3044\u3044\u3068\u601d\u3046\u306e\u3067\u3059\u304c\u3001\u30b7\u30f3\u30d7\u30eb\u306b\u8003\u3048\u308b\u3068<\/p>\n<p><code>\u300c\u3069\u3093\u306a\u306b\u9ad8\u8ca0\u8377\u306a\u72b6\u614b\u3067\u3042\u3063\u305f\u3068\u3057\u3066\u3082\u3001\u5b89\u5b9a\u3057\u3066\u540c\u6642\u306bInnoDB\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u300d\u3068\u3044\u3046\u30b9\u30ec\u30c3\u30c9\u6570\u306e\u4e0a\u9650\u3092\u3001\u30ef\u30fc\u30b9\u30c8\u30b1\u30fc\u30b9\u3068\u3057\u3066\u8003\u3048\u3066\u8a2d\u5b9a\u3059\u308b<\/code><\/p>\n<p>\u3068\u3044\u3046\u3060\u3051\u306e\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u500b\u4eba\u7684\u306a\u898b\u89e3\u3092\u4ea4\u3048\u3064\u3064\u8a00\u3044\u63db\u3048\u308b\u3068<\/p>\n<p><code>\uff08sync array \u306e\u4ed5\u7d44\u307f\u3092\u8e0f\u307e\u3048\u308b\u3068\uff09pthread_cond_broadcast()\u3067\u4e00\u5ea6\u306b\u8d77\u5e8a\u3055\u305b\u305f\u3044\u30b9\u30ec\u30c3\u30c9\u6570\u306e\u4e0a\u9650\u306f\u3044\u304f\u3089\u304b<\/code><\/p>\n<p>\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u5f0a\u793e\u3067\u306f\u3001 I\/O bound \u306a mysqld \u306f\u305d\u308c\u307b\u3069\u591a\u304f\u306a\u3044\u306e\u3067\u3001\u6b21\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u308b\u3068\u3053\u308d\u304c\u5927\u90e8\u5206\u3067\u3059\u3002<\/p>\n<p><code>innodb_thread_concurrency = CPU\u306eCore\u6570\uff08Hyper-Threading\u6709\u52b9\u306b\u3057\u305f\u3068\u304d\u306e\u8ad6\u7406\u30b3\u30a2\u6570\uff09<\/code><\/p>\n<p>\u3054\u304f\u3054\u304f\u7a00\u306b\u3001EBS\u306a\u3069\u304c\u91cd\u304f\u3066CPU\u4f7f\u3044\u5207\u308b\u524d\u306binnodb_thread_concurrency\u3067\u8a2d\u5b9a\u3057\u305f\u4e0a\u9650\u306b\u9054\u3059\u308b\u30b1\u30fc\u30b9\u3082\u6709\u308b\u306e\u3067\u3059\u304c\u3001\u300c\u304b\u3068\u3044\u3063\u3066innodb_thread_concurrency=0\u306e\u307e\u307e\u3060\u3068\u3001spin lock \u3067CPU\u6301\u3063\u3066\u3044\u304b\u308c\u3066\u3001\u7d50\u5c40mysqld\u304cSQL\u634c\u304f\u305f\u3081\u306bCPU\u3046\u307e\u304f\u4f7f\u3044\u5207\u308c\u306a\u3044\u3053\u3068\u3082\u3042\u308a\u3048\u308b\u3057\u300d\u3068\u3001\u3042\u308b\u7a0b\u5ea6\u5272\u308a\u5207\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001RDS for MySQL \u306a\u3069\u3001\u4ed5\u7d44\u307f\u4e0a I\/O \u304c\u91cd\u304f\u306a\u308b\u3068\u6700\u521d\u304b\u3089\u308f\u304b\u3063\u3066\u3044\u308b\u3082\u306e\u3067\u3042\u308c\u3070\u3001 \u6b21\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u305f\u3068\u3053\u308d\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<p><code>innodb_thread_concurrency = CPU\u306eCore\u6570\uff08Hyper-Threading\u6709\u52b9\u306b\u3057\u305f\u3068\u304d\u306e\u8ad6\u7406\u30b3\u30a2\u6570\uff09*2<\/code><\/p>\n<p>innodb_thread_concurrency\u3092\u521d\u3081\u30660\u4ee5\u5916\u306e\u5024\u306b\u3059\u308b\u3068\u304d\u3001\u4ed6\u306b\u306a\u306b\u304b\u53c2\u8003\u306b\u306a\u308b\u3082\u306e\u304c\u3042\u308b\u3068\u3057\u305f\u3089\u3001\u3057\u3044\u3066\u8a00\u3048\u3070Threads_running\u304b\u306a\u3041\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h3><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.6\/ja\/server-status-variables.html#statvar_Threads_running\">Threads_running<\/a><\/h3>\n<p>\u3053\u306e\u5024\u306f mysqld \u306e\u4e2d\u3067\u30b9\u30ea\u30fc\u30d7\u72b6\u614b\u3067\u306f\u306a\u3044\u30b9\u30ec\u30c3\u30c9\u6570\u306a\u306e\u3067\u3001 Binlog Dump Thread \u306a\u3069\u3082\u542b\u307e\u308c\u3001InnoDB \u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3044\u306a\u3044\u30b9\u30ec\u30c3\u30c9\u3082\u542b\u307e\u308c\u307e\u3059\u3002\u3088\u3063\u3066\u3001Threads_running\u306finnodb_thread_concurrency\u306e\u6700\u9069\u5024\u3088\u308a\u5927\u304d\u3044\u5024\u306b\u306a\u308b\u3068\u601d\u3046\u306e\u3067\u3059\u304c\u3001\u4ed6\u306b\u4f55\u3082\u57fa\u6e96\u3068\u306a\u308b\u5024\u304c\u306a\u3044\u72b6\u614b\u3067\u3042\u308c\u3070\u3001\u6700\u521d\u306fThreads_running\u3092\u898b\u308c\u3070\u3088\u3044\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002\u5b9f\u969b\u3001\u79c1\u306f\u6700\u521d\u306bThreads_running\u3092\u773a\u3081\u3066\u8003\u3048\u307e\u3057\u305f\u3002<\/p>\n<h2>Monitoring\u306e\u30dd\u30a4\u30f3\u30c8<\/h2>\n<p>\u3067\u306f\u3001innodb_thread_concurrency\u30920\u4ee5\u5916\u306e\u5024\u306b\u3057\u305f\u5834\u5408\u3001\u3069\u306emetric\u3092monitoring\u3057\u3066\u884c\u3051\u3070\u3088\u3044\u306e\u3067\u3057\u3087\u3046\u304b\u3002\u308f\u304b\u308a\u3084\u3059\u3044\u3068\u3053\u308d\u3067\u3044\u3046\u3068\u3001mysqld\u304c\u523a\u3055\u3063\u305f\u3068\u304d\u3001 load average \u306a\u3069\u306b\u3082\u73fe\u308c\u307e\u3059\u3002innodb_thread_concurrency\u304c0\u3060\u3068\u3001mysqld\u304c\u523a\u3055\u3063\u305f\u3068\u304d\u306b load average \u304c\u6570\u767e\u306b\u9054\u3057\u3066\u3082\u304a\u304b\u3057\u304f\u306f\u306a\u3044\u3067\u3059\u304c\u3001innodb_thread_concurrency\u304c0\u4ee5\u5916\u306e\u3068\u304d\u3001innodb_thread_concurrency\u306b\u6e96\u3058\u3066 load average\u306f\u3042\u308b\u7a0b\u5ea6\u4f4e\u3044\u5024\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u304b\u3068\u3044\u3063\u3066\u3001mysqld\u304c\u523a\u3055\u308b\u307e\u3067\u4f55\u3082\u898b\u308b\u3082\u306e\u304c\u306a\u3044\u304b\u3068\u3044\u3046\u3068\u3001\u5024\u306b\u306a\u3063\u3066\u73fe\u308c\u308b\u3082\u306e\u3082\u3042\u308a\u307e\u3059\u3002 \u4f8b\u3048\u3070\u3001\u6b21\u306e\u3088\u3046\u306a\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h3>SHOW ENGINE INNODB STATUS \u306equeries inside InnoDB\u3068queries in queue<\/h3>\n<p>queries inside InnoDB\u304c\u5b9f\u969b\u306bSQL\u3092\u5b9f\u884c\u3057\u3066\u3044\u308b\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30b9\u30ec\u30c3\u30c9\u6570\u3001queries in queue\u304c\u3001innodb_thread_sleep_delay\u306e\u3076\u3093nanosleep\u3057\u3066\u3044\u308b\u30b9\u30ec\u30c3\u30c9\u6570\u3001\u30ad\u30e5\u30fc\u306e\u9577\u3055\u3068\u306a\u308a\u307e\u3059\u3002\u4f59\u8ac7\u3067\u3059\u304c\u3001queries in queue\u306e\u6700\u5927\u9577\u306f\u3001\u7406\u8ad6\u4e0a\u3060\u3044\u305f\u3044max_connections\u7a0b\u5ea6\u306b\u306a\u308b\u306e\u304b\u306a\uff1f\u3068\u79c1\u306f\u8a8d\u8b58\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.6\/ja\/innodb-parameters.html#sysvar_innodb_adaptive_max_sleep_delay\">innodb_adaptive_max_sleep_delay<\/a>, <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.6\/ja\/innodb-parameters.html#sysvar_innodb_thread_sleep_delay\">innodb_thread_sleep_delay<\/a><\/h3>\n<p>mysqld\u304c\u5fd9\u3057\u304f\u306a\u308c\u3070\u306a\u308b\u307b\u3069\u3001 innodb_thread_sleep_delay \u304c\u5897\u3048\u3066\u3044\u304d\u307e\u3059\u3002\u305d\u306e\u6642\u9593\u3060\u3051nanosleep\u3057\u3066\u3044\u308b\u305f\u3081\u3001mysqld\u306e\u5fdc\u7b54\u3092\u5f85\u3064\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d0\u3084\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306f\u3001\u305d\u306e\u6642\u9593\u3060\u3051\u9577\u304f\u5f85\u305f\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u5fdc\u7b54\u6642\u9593\u306b\u306f\u9069\u6b63\u5024\u304c\u3042\u308b\u3067\u3057\u3087\u3046\u304b\u3089\u3001innodb_thread_sleep_delay\u304c\u5897\u3048\u3059\u304e\u3066\u3044\u308b\u3068\u601d\u308f\u308c\u305f\u3068\u304d\u306f\u3001\u306a\u3093\u3089\u304b\u306e\u5bfe\u5fdc\u3092\u3057\u3066\u3082\u3088\u3044\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<h2>\u88dc\u8db3\uff11\uff1ainnodb_concurrency_tickets\u306b\u3064\u3044\u3066\u306f\u3069\u306e\u3088\u3046\u306b\u8003\u3048\u308b\u306e\u304b<\/h2>\n<p>\u6b63\u76f4\u3001\u308f\u305f\u3057\u306f\u307e\u3060innodb_concurrency_tickets\u3092\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u3057\u3088\u3046\u3068\u601d\u3063\u305f\u3053\u3068\u304c\u3001innodb_concurrency_tickets\u3044\u3058\u3089\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u307b\u3069\u56f0\u3063\u305f\u3053\u3068\u304c\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\nSHOW ENGINE INNNODB STATUS \u53e9\u304f\u3068\u3001\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u5b9f\u884c\u4e2d\u306e\u30b9\u30ec\u30c3\u30c9\u306e<a href=\"https:\/\/github.com\/mysql\/mysql-server\/blob\/7cfee48560e1b08384da3a1e245d5b125e2ef36b\/storage\/innobase\/trx\/trx0trx.cc#L2547-L2550\">\u6b8b\u308a\u30c1\u30b1\u30c3\u30c8\u6570<\/a>\u3092\u898b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u9006\u306b\u3044\u3046\u3068\u3001\u4e00\u3064\u4e00\u3064\u306eSQL\u306e\u5b9f\u884c\u6642\u9593\u304c\u3054\u304f\u3054\u304f\u77ed\u3044\u306e\u3067\u3042\u308c\u3070\u3001Monitoring\u3059\u308b\u3053\u3068\u3055\u3048\u56f0\u96e3\u306a\u306e\u3067\u3001\u3042\u307e\u308a\u6c17\u306b\u3057\u306a\u304f\u3066\u3082\u826f\u3044\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002\u305d\u308c\u3088\u308a\u3082\u3001\u78ba\u5b9f\u306b\u89b3\u6e2c\u3067\u304d\u308b\u4e8b\u8c61\u3092\u512a\u5148\u3057\u3066\u6539\u5584\u3057\u3066\u3044\u3051\u3070\u826f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/mysql\/mysql-server\/blob\/7cfee48560e1b08384da3a1e245d5b125e2ef36b\/storage\/innobase\/handler\/ha_innodb.cc#L8607-L8647\">5.7\u306eha_innobase::index_read()<\/a>\u3084<a href=\"https:\/\/github.com\/mysql\/mysql-server\/blob\/7cfee48560e1b08384da3a1e245d5b125e2ef36b\/storage\/innobase\/handler\/ha_innodb.cc#L8915-L8939\">ha_innobase::general_fetch()<\/a>\u3092\u8aad\u3080\u9650\u308a\u3001<\/p>\n<ol>\n<li>\u30c1\u30b1\u30c3\u30c8\u6b8b\u3063\u3066\u305f\u3089 innobase_srv_conc_enter_innodb() \u3067\u4f7f\u3063\u3066<\/li>\n<li>\u884c\u8aad\u3093\u3067<\/li>\n<li>srv_stats.n_rows_read.add() \u3067 InnoDB_rows_read \u304c +1 \u3055\u308c\u308b<\/li>\n<\/ol>\n<p>\u3088\u3046\u306a\u306e\u3067\u3001\u4e00\u3064\u306eSQL\u3092\u5b9f\u884c\u3059\u308b\u3068\u304d\u3001\u5c11\u306a\u304f\u3068\u3082 Rows_examined \u306e\u6570\u306f\u30c1\u30b1\u30c3\u30c8\u3092\u4f7f\u3046\u307f\u305f\u3044\u3067\u3059\u304b\u3089\u3001 Rows_examined \u304c\u30c7\u30d5\u30a9\u30eb\u30c8\u306e innodb_concurrency_tickets \u3088\u308a\u5145\u5206\u5c0f\u3055\u3044OLTP\u306e\u7528\u9014\u3067\u3042\u308c\u3070\u3001\u3072\u3068\u307e\u305a\u8003\u3048\u306a\u304f\u3066\u826f\u3044\u306e\u3067\u306f\uff1f\u305d\u306e\u524d\u306bSQL\u76f4\u3057\u3066Rows_examined\u5c0f\u3055\u304f\u3059\u308b\u65b9\u304c\u5efa\u8a2d\u7684\u306a\u306e\u3067\u306f\uff1f\u3068\u601d\u3046\u306a\u3069\u3057\u307e\u3059\u3002<\/p>\n<h2>\u88dc\u8db3\uff12\uff1ainnodb_commit_concurrency\u306b\u3064\u3044\u3066\u306f\u3069\u306e\u3088\u3046\u306b\u8003\u3048\u308b\u306e\u304b<\/h2>\n<p>\u4e16\u306b\u3042\u308b\u904e\u53bb\u306eblog\u306a\u3069\u3092\u8aad\u3080\u3068\u3001innodb_thread_concurrency\u3068\u30bb\u30c3\u30c8\u3067innodb_commit_concurrency\u3068\u3044\u3046\u3082\u306e\u304c\u51fa\u3066\u304f\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u6975\u3081\u3066\u500b\u4eba\u7684\u306a\u898b\u89e3\u3067\u3059\u304c\u3001innodb_commit_concurrency\u304c\u8a00\u53ca\u3055\u308c\u3066\u3044\u305f\u6642\u4ee3\u3060\u3068\u3001 InnoDB Adaptive Flushing \u306f\u4eca\u307b\u3069\u8ce2\u304f\u3042\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u73fe\u4ee3\u306b\u304a\u3044\u3066\u306f\u3001\u5148\u305a\u306f InnoDB Adaptive Flushing \u306b\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u306e\u4f59\u5730\u304c\u306a\u3044\u304b\u3001\u78ba\u8a8d\u3057\u3066\u307f\u308b\u65b9\u304c\u826f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u305f\u3044\u3078\u3093\u3056\u3063\u304f\u308a\u8a00\u3044\u307e\u3059\u3068\u3001innodb_commit_concurrency\u306fI\/O\u3067\u523a\u3055\u308b\u306e\u3092\u6291\u5236\u3059\u308b\u305f\u3081\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u304b\u3068\u601d\u3044\u307e\u3059\u3002 block device \u306f read only or write only \u3088\u308a\u3001read \u3068 write \u304c\u6df7\u5728\u3059\u308b\u3068\u91cd\u3044\u3067\u3059\u304c\u3001 write \u306e\u983b\u5ea6\u3084\u6bd4\u7387\u3092\u6e1b\u3089\u3059\u3053\u3068\u3067\u3001 read \u3092\u305d\u306e\u3076\u3093\u8efd\u304f\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 InnoDB Adaptive Flushing \u306e\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u3067 write \u306f\u3042\u308b\u3066\u3044\u3069\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u3067\u304d\u308b\u306e\u3067\u3001\u79c1\u306finnodb_commit_concurrency\u3088\u308a\u5148\u306b\u3001InnoDB Adaptive Flushing\u306e\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u3092\u304a\u3059\u3059\u3081\u3057\u307e\u3059\u3002<\/p>\n<p>\u203bdisk I\/O \u3084InnoDB Adaptive Flushing\u306e\u8a71\u3092\u59cb\u3081\u308b\u3068\u307e\u3063\u305f\u304f\u3082\u3063\u3066\u7d19\u5e45\u304c\u8db3\u308a\u306a\u3044\u306e\u3067\u3001\u4eca\u56de\u306f\u3053\u306e\u3078\u3093\u306b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<h2>MySQL8.0 \u3067\u306f\u3001\u3055\u3089\u306b\u4f55\u304c\u6539\u5584\u3055\u308c\u305f\u306e\u304b<\/h2>\n<p>MySQL8.0\u3067\u306f\u3001innodb_thread_concurrency\u5468\u308a\u304c\u76f4\u63a5\u6539\u5584\u3055\u308c\u305f\u308f\u3051\u3067\u306f\u306a\u3044\uff08\u3068\u3001\u3044\u307e\u306e\u3068\u3053\u308d\u8a8d\u8b58\u3057\u3066\u3044\u307e\u3059\uff09\u304c\u3001\u3053\u3046\u3044\u3063\u305fInnoDB\u306e\u30ed\u30c3\u30af\u306e\u7af6\u5408\u5468\u308a\u3067\u3001\u5927\u304d\u306a\u6539\u5584\u304c\uff12\u3064\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li><a href=\"https:\/\/dev.mysql.com\/blog-archive\/mysql-8-0-new-lock-free-scalable-wal-design\/\">MySQL 8.0: New Lock free, scalable WAL design<\/a><\/li>\n<li><a href=\"https:\/\/dev.mysql.com\/blog-archive\/contention-aware-transaction-scheduling-arriving-in-innodb-to-boost-performance\/\">Contention-Aware Transaction Scheduling Arriving in InnoDB to Boost Performance<\/a><\/li>\n<\/ul>\n<p>\"New Lock free, scalable WAL design\" \u306e\u8a18\u4e8b\u3067\u66f8\u304b\u308c\u3066\u3044\u308b\u65b9\u306f\u3001MySQL8.0\u306eGA\u304c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u308b\u524d\u3001<a href=\"https:\/\/labs.mysql.com\/\">MySQL Labs<\/a>\u3067\u516c\u958b\u3055\u308c\u3066\u3044\u305f\u306e\u3067\u3001\u79c1\u306e\u65b9\u3067\u3082\u8a55\u4fa1\u3057\u3001\u30d5\u30a3\u30fc\u30c9\u30d0\u30c3\u30af\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3057\u305f\u3002InnoDB\u306eI\/O\u306b\u95a2\u3059\u308b\u3082\u306e\u306a\u306e\u3067\u3002\u3053\u306e redo log \u306e\u6700\u9069\u5316\u304c\u5165\u3063\u305f\u3053\u3068\u306b\u3088\u308a\u3001\u3088\u308a\u4e00\u5c64\u3001innodb_commit_concurrency \u306f\u6c17\u306b\u3057\u306a\u304f\u3066\u3082\u826f\u304f\u306a\u3063\u305f\u306e\u3067\u306f\uff1f\u3068\u601d\u3046\u306a\u3069\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>Contention-Aware Transaction Scheduling \u306b\u3064\u3044\u3066\u306f\u3001\u6628\u5e74Sunny\u306b\u4f1a\u3063\u305f\u3068\u304d\u306b\u300c\u3053\u308c\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u307e\u3060\u8aad\u3093\u3067\u306a\u3044\u3051\u3069\u3001WorkLog\u898b\u308b\u9650\u308agood patch\u3060\u3088\u306d\u300d\u7684\u306a\u3053\u3068\u3092\u4f1d\u3048\u305f\u306e\u3067\u3059\u304c\u3001\u6628\u5e74\u306e Oracle Open World \u306e\u30bb\u30c3\u30b7\u30e7\u30f3\u3067 Sunny \u3082\u300cgood patch\u3060\u300d\u3068\u7d39\u4ecb\u3057\u3066\u305f\u6a5f\u80fd\u306a\u306e\u3067\u3001\u3051\u3063\u3053\u3046\u671f\u5f85\u3057\u3066\u307e\u3059\u3002\u79c1\u3068\u3057\u3066\u306f\u3001MySQL8.0\u306b\u79fb\u884c\u3059\u308b\u30e2\u30c1\u30d9\u30fc\u30b7\u30e7\u30f3\u306e\u4e00\u3064\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u6642\u9593\u304c\u3067\u304d\u305f\u3089\u3053\u306e\u3078\u3093\u306e\u30b3\u30fc\u30c9\u3082\u8aad\u307f\u305f\u3044\u3068\u3053\u308d\u3067\u3059\u3002<\/p>\n<h2>\u304a\u308f\u308a\u306b<\/h2>\n<p>\u4eca\u56de\u306f\u601d\u3063\u305f\u4ee5\u4e0a\u306b\u9577\u304f\u306a\u3063\u3066\u3057\u307e\u3063\u305f\u306e\u3067\u3001\u6b21\u56de\u306f\u8efd\u3081\u306b\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h2>References<\/h2>\n<p>\u6642\u7cfb\u5217\u306b\u4e26\u3079\u3066\u3042\u308a\u307e\u3059\u306e\u3067\u3001 InnoDB \u306eCPU\u30b9\u30b1\u30fc\u30e9\u30d3\u30ea\u30c6\u30a3\u306b\u3064\u3044\u3066\u632f\u308a\u8fd4\u308b\u306e\u306b\u3088\u308d\u3057\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li><a href=\"https:\/\/www.percona.com\/blog\/2006\/06\/05\/innodb-thread-concurrency\/\">InnoDB thread concurrency<\/a><\/li>\n<li><a href=\"https:\/\/www.percona.com\/blog\/2007\/11\/01\/innodb-performance-optimization-basics\/\">Innodb Performance Optimization Basics<\/a><\/li>\n<li><a href=\"http:\/\/dimitrik.free.fr\/blog\/archives\/2009\/07\/entry_64.html\">MySQL Performance: Once again about InnoDB thread concurrency...<\/a><\/li>\n<li><a href=\"https:\/\/www.percona.com\/blog\/2010\/05\/24\/tuning-innodb-concurrency-tickets\/\">Tuning InnoDB Concurrency Tickets<\/a><\/li>\n<li><a href=\"http:\/\/dimitrik.free.fr\/blog\/archives\/2010\/11\/mysql-performance-55-and-innodb-thread-concurrency.html\">MySQL Performance: 5.5 and InnoDB thread concurrency<\/a><\/li>\n<li><a href=\"https:\/\/enterprisezine.jp\/dbonline\/detail\/3829?p=3\">MySQL\u3000InnoDB\u30b9\u30c8\u30ec\u30fc\u30b8\u30a8\u30f3\u30b8\u30f3\u306e\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\uff08\u5f8c\u7de8\uff09<\/a><\/li>\n<li><a href=\"https:\/\/www.percona.com\/blog\/2013\/09\/20\/innodb-performance-optimization-basics-updated\/\">InnoDB performance optimization basics (redux)<\/a><\/li>\n<li><a href=\"http:\/\/buildup-db.blogspot.com\/2015\/03\/innodb-deep-talk-2.html\">InnoDB Deep Talk #2 (\u4eee) \u306b\u5f15\u3063\u5f35\u308a\u3060\u3055\u308c\u307e\u3057\u305f\u3002<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u308f\u3002\u305b\u3058\u307e\u3067\u3059\u3002\u4eca\u56de\u306e\u8a71\u306f\u8efd\u304f\u66f8\u3053\u3046\u3068\u601d\u3063\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u9577\u304f\u306a\u308a\u307e\u3057\u305f\u3002\u307e\u3041InnoDB\u306e\u8a71\u306a\u306e\u3067\u3057\u3087\u3046\u304c\u306a\u3044\u3067\u3059\u306d\u3002 \u306f\u3058\u3081 \u4eca\u56de\u306finnodb_thread_concurrency\u306b\u3064\u3044\u3066\u304a\u8a71\u3057\u3088\u3046\u3068\u601d\u3044\u307e [&hellip;]<\/p>\n","protected":false},"author":137,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[17],"class_list":["post-17003","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-info","tag-mysql"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/17003","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/users\/137"}],"replies":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/comments?post=17003"}],"version-history":[{"count":3,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/17003\/revisions"}],"predecessor-version":[{"id":21460,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/17003\/revisions\/21460"}],"wp:attachment":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/media?parent=17003"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/categories?post=17003"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/tags?post=17003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}