{"id":834,"date":"2023-05-09T02:37:50","date_gmt":"2023-05-08T17:37:50","guid":{"rendered":"https:\/\/shinke1987.net\/?p=834"},"modified":"2023-05-09T02:37:51","modified_gmt":"2023-05-08T17:37:51","slug":"event-mpm-%e3%81%ae%e3%83%81%e3%83%a5%e3%83%bc%e3%83%8b%e3%83%b3%e3%82%b0","status":"publish","type":"post","link":"https:\/\/shinke1987.net\/?p=834","title":{"rendered":"event MPM \u306e\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0"},"content":{"rendered":"\n<h2 id=\"toc0\" class=\"wp-block-heading\">\u3084\u308a\u305f\u3044\u3053\u3068<\/h2>\n\n\n\n<p>\u30b5\u30fc\u30d0\u304c\u91cd\u304f\u306a\u308b\u306e\u306f\u3057\u3087\u3046\u304c\u306a\u3044\u3068\u3057\u3066\u3001\u843d\u3061\u306a\u3044\u3088\u3046\u306b\u3057\u305f\u3044\u3002<br>\u203b prefork MPM\u306e\u6642\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3060\u3068ab\u3092\u5229\u7528\u3057\u305f\u8ca0\u8377\u30c6\u30b9\u30c8\u3067Apache\u304c\u843d\u3061\u305f\u3051\u3069\u3001event MPM\u3060\u3068\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u72b6\u614b\u3067\u3001prefork\u306e\u6642\u3068\u540c\u3058\u6761\u4ef6\u306e\u8ca0\u8377\u30c6\u30b9\u30c8\u3067\u843d\u3061\u308b\u3053\u3068\u306f\u306a\u304f\u306a\u3063\u3066\u3044\u305f\u306e\u3067\u9032\u6b69\u3092\u611f\u3058\u3066\u3046\u308c\u3057\u304f\u601d\u3063\u305f\u3002<\/p>\n\n\n\n<h2 id=\"toc1\" class=\"wp-block-heading\">\u4f7f\u7528\u3059\u308b\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u540d<\/td><td>\u8aac\u660e<\/td><\/tr><tr><td>ThreadsPerChild<\/td><td>\u5404\u5b50\u30d7\u30ed\u30bb\u30b9\u3067\u7528\u610f\u3055\u308c\u308b\u30b9\u30ec\u30c3\u30c9\u6570\u3092\u5236\u9650\u3059\u308b\u3002<br>\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\uff1a25<br>\u8a08\u7b97\u5f0f\uff1aThreadsPerChild = MaxRequestWorkers \u00f7 ServerLimit<\/td><\/tr><tr><td>MaxRequestWorkers<\/td><td>\u540c\u6642\u63a5\u7d9a\u6570\u306e\u6700\u5927\u5024\u3092\u5236\u9650\u3059\u308b\u3002<br>\u8a08\u7b97\u5f0f\uff1aMaxRequestWorkers = ServerLimit \u00d7 ThreadsPerChild<\/td><\/tr><tr><td>StartServers<\/td><td>\u8d77\u52d5\u6642\u306e\u30d7\u30ed\u30bb\u30b9\u7dcf\u6570\u3092\u8a2d\u5b9a\u3059\u308b\u3002<br>\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\uff1a3<\/td><\/tr><tr><td>MinSpareThreads<\/td><td>\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u5fdc\u7b54\u3059\u308b\u3053\u3068\u306e\u3067\u304d\u308b\u30a2\u30a4\u30c9\u30eb\u30b9\u30ec\u30c3\u30c9\u6570\u306e\u6700\u5c0f\u5024\u3092\u8a2d\u5b9a\u3059\u308b\u3002<\/td><\/tr><tr><td>MaxSpareThreads<\/td><td>\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u5fdc\u7b54\u3059\u308b\u3053\u3068\u306e\u3067\u304d\u308b\u30a2\u30a4\u30c9\u30eb\u30b9\u30ec\u30c3\u30c9\u6570\u306e\u6700\u5927\u5024\u3092\u8a2d\u5b9a\u3059\u308b\u3002<\/td><\/tr><tr><td>ServerLimit<\/td><td>\u30b5\u30fc\u30d0\u30d7\u30ed\u30bb\u30b9\u6570\u306e\u4e0a\u9650\u3092\u5236\u9650\u3059\u308b\u3002<br>\u8a08\u7b97\u5f0f\uff1aServerLimit = MaxRequestWorker \u00f7 ThreadsPerChild<\/td><\/tr><tr><td>MaxConnectionsPerChild<\/td><td>1\u3064\u306e\u30d7\u30ed\u30bb\u30b9\u304c\u53d7\u3051\u4ed8\u3051\u308b\u3053\u3068\u306e\u3067\u304d\u308b\u63a5\u7d9a\u6570\u3092\u8a2d\u5b9a\u3059\u308b\u3002<br>0\u304c\u6307\u5b9a\u3055\u308c\u305f\u5834\u5408\u3001\u30d7\u30ed\u30bb\u30b9\u306f\u305a\u3063\u3068\u518d\u5229\u7528\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308b\u3002<br>\u3082\u3057\u30e1\u30e2\u30ea\u30ea\u30fc\u30af\u304c\u8d77\u3053\u3063\u305f\u6642\u306e\u305f\u3081\u306b\u3053\u306e\u8a2d\u5b9a\u3092\u884c\u3046\u3002<\/td><\/tr><tr><td>AsyncRequestWorkerFactor<\/td><td>\u5404\u30d7\u30ed\u30bb\u30b9\u306e\u540c\u6642\u63a5\u7d9a\u6570\u3092\u5236\u9650\u3059\u308b\u3002<br>\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\uff1a2<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 id=\"toc2\" class=\"wp-block-heading\">\/etc\/php-fpm.d\/www.conf<\/h2>\n\n\n\n<p>\u4e0b\u8a18\u5185\u5bb9\u3067\u8a2d\u5b9a\u3057\u3066\u3044\u308b\uff08\u30d7\u30ed\u30bb\u30b9\u306e\u6570\u306f2\u3067\u56fa\u5b9a\u3055\u308c\u308b\uff09<br>pm = static<br>pm.max_children = 2<\/p>\n\n\n\n<h2 id=\"toc3\" class=\"wp-block-heading\">\u4f7f\u7528\u30e1\u30e2\u30ea\u91cf\u306e\u8003\u3048\u65b9<\/h2>\n\n\n\n<h3 id=\"toc4\" class=\"wp-block-heading\">\u6982\u8981<\/h3>\n\n\n\n<p>\u203b \u3053\u306e\u8003\u3048\u65b9\u304c\u9593\u9055\u3063\u3066\u3044\u308b\u53ef\u80fd\u6027\u3082\u3042\u308b\u306e\u3067\u3001\u6ce8\u610f\u3002<\/p>\n\n\n\n<p>Web\u30b5\u30fc\u30d0\u4ee5\u5916\u3067\u3082\u4f7f\u7528\u3059\u308b\u4e88\u5b9a\u306a\u3089\u3001\u305d\u308c\u3092\u8e0f\u307e\u3048\u3066\u3069\u308c\u3060\u3051\u30e1\u30e2\u30ea\u3092\u4f7f\u3044\u305f\u3044\u304b\u8003\u3048\u308b\u3002<br>1GB\u306e\u30e1\u30e2\u30ea\u3057\u304b\u7a4d\u3093\u3067\u3044\u306a\u3044\u306e\u3067\u3001\u3068\u308a\u3042\u3048\u305a600MB\u3092Web\u30b5\u30fc\u30d0\u3068PHP-FPM\u3067\u4f7f\u3046\u3053\u3068\u306b\u3059\u308b\u3002<\/p>\n\n\n\n<p>\u4f7f\u7528\u30e1\u30e2\u30ea\u91cf\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306b\u3001\u4e0b\u8a18\u306eab\u30b3\u30de\u30f3\u30c9\u3092\u5229\u7528\u3057\u3066\u8ca0\u8377\u3092\u304b\u3051\u305f\u3002<br><pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ ab -n 100 -c 100 http:\/\/\u30c9\u30e1\u30a4\u30f3\u540d\/<\/pre><\/p>\n\n\n\n<h3 id=\"toc5\" class=\"wp-block-heading\">php-fpm\u306e\u4f7f\u7528\u30e1\u30e2\u30ea\u91cf\u30e1\u30e2<\/h3>\n\n\n\n<p>\u5b9f\u884c\u30e6\u30fc\u30b6\u304croot\u306e\u30d7\u30ed\u30bb\u30b9\u304c1\u3064\u3001<br>\u5b9f\u884c\u30e6\u30fc\u30b6\u304capache\u306e\u30d7\u30ed\u30bb\u30b9\u304c2\u3064\u3001<br>\u5408\u8a083\u3064\u306e\u30d7\u30ed\u30bb\u30b9\u304c\u8d70\u3063\u3066\u3044\u305f\u3002<br>root\u306e\u30d7\u30ed\u30bb\u30b9\u306f66400KiB\u4f7f\u7528\u3057\u3066\u3044\u305f\u3002<br>apache\u306e1\u3064\u3081\u306e\u30d7\u30ed\u30bb\u30b9\u306f59880KiB\u30012\u3064\u3081\u306e\u30d7\u30ed\u30bb\u30b9\u306f58664KiB\u4f7f\u7528\u3057\u3066\u3044\u305f\u3002<br>\u5408\u8a08\u306f127,236KiB\u3002<br>PHP-FPM\u306e\u30d7\u30ed\u30bb\u30b9\u6570\u306f2\u3067\u56fa\u5b9a\u3057\u3066\u3044\u308b\u306e\u3067\u3001<br>\u30b5\u30a4\u30c8\u306b\u5927\u304d\u306a\u5909\u66f4\u3092\u3057\u306a\u3044\u9650\u308a\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3082\u5927\u304d\u304f\u5909\u308f\u3089\u306a\u3044\u306f\u305a\u3002<\/p>\n\n\n\n<p>root\u306e\u30d7\u30ed\u30bb\u30b9\u304c70MB\u4f7f\u7528\u3001<br>apache\u306e\u30d7\u30ed\u30bb\u30b9\u304c1\u500b\u3042\u305f\u308a80MB\u4f7f\u7528\u3059\u308b\u3068\u8003\u3048\u3066\u3001<br>PHP-FPM\u5168\u4f53\u3067\u306e\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf = 70MB + 80MB \u00d7 2 = 230MB \u3068\u306a\u308b\u3002<\/p>\n\n\n\n<h3 id=\"toc6\" class=\"wp-block-heading\">Apache\u306e\u4f7f\u7528\u30e1\u30e2\u30ea\u91cf\u30e1\u30e2<\/h3>\n\n\n\n<p>600MB\u306e\u30e1\u30e2\u30ea\u3092Apache\u3068PHP-FPM\u3067\u4f7f\u3044\u305f\u3044\u306e\u3067\u3001<br>Apache\u306b\u5272\u308a\u5f53\u3066\u308b\u30e1\u30e2\u30ea\u91cf = 600MB &#8211; 230MB = 370 MB \u3068\u306a\u308b\u3002<\/p>\n\n\n\n<p>Apache\u306eroot\u306e\u30d7\u30ed\u30bb\u30b9\u306f\u7d0415MB\u4f7f\u7528\u3001<br>Apache\u306eapache\u30e6\u30fc\u30b6\u306e\u30d7\u30ed\u30bb\u30b9\u304c1\u500b\u3042\u305f\u308a40MB\u4f7f\u7528\u3059\u308b\u3068\u8003\u3048\u308b\u3068\u3001<br>\uff08\u5b9f\u969b\u306b\u306f20MB\u3050\u3089\u3044\u3060\u3063\u305f\u3051\u3069\uff09<br>\u30d7\u30ed\u30bb\u30b9\u6570 = 370MB \u00f7 40MB = 9.25 \u3068\u306a\u308b\u306e\u3067\u3001<br>Apache\u306eapache\u30e6\u30fc\u30b6\u306e\u30d7\u30ed\u30bb\u30b9\u6570\u306f9\u500b\u3068\u3059\u308b\u3002<\/p>\n\n\n\n<h2 id=\"toc7\" class=\"wp-block-heading\">\u5404\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u306e\u5024\u306e\u8003\u3048\u65b9<\/h2>\n\n\n\n<p>Apache\u306e\u30d7\u30ed\u30bb\u30b9\u6570\u306e\u4e0a\u9650\u306f9\u500b\u3067\u6c7a\u5b9a\u3057\u305f\u306e\u3067\u3001<br>ServerLimit\u306e\u5024\u306f9\u306b\u306a\u308b\u3002<\/p>\n\n\n\n<p>ThreadsPerChild\u306e\u5024\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u306e25\u306e\u307e\u307e\u306b\u3057\u3066\u304a\u304f\u3002<br>\u8ca0\u8377\u3092\u304b\u3051\u305f\u6642\u3082\u3053\u306e\u5024\u306a\u306e\u3067\u300125\u3088\u308a\u5927\u304d\u306a\u6570\u5024\u306b\u3059\u308b\u3068\u524d\u56de\u8003\u3048\u305f\u4f7f\u7528\u30e1\u30e2\u30ea\u91cf\u304c\u53c2\u8003\u306b\u306a\u3089\u306a\u304f\u306a\u308b\u3002<\/p>\n\n\n\n<p>MaxRequestWorkers = ServerLimit \u00d7 ThreadsPerChild<br>\u3067\u8a08\u7b97\u3059\u308b\u306e\u3067\u3001<br>MaxRequestWorkers\u306f225\u306b\u306a\u308b\u3002<\/p>\n\n\n\n<p>Apache\u306emod_status\u306b\u3088\u308b\u30b9\u30c6\u30fc\u30bf\u30b9\u30da\u30fc\u30b8\u3092\u898b\u305f\u9650\u308a\u3067\u306f\u3001<br>1\u30d7\u30ed\u30bb\u30b9\u3042\u305f\u308a\u306e\u30b9\u30ec\u30c3\u30c9\u6570\u306f25\u304c\u533a\u5207\u308a\u306b\u306a\u3063\u3066\u3044\u308b\u3088\u3046\u306a\u306e\u3067\u3001<br>MinSpareThreads\u306f25\u306b\u3059\u308b\u3002<\/p>\n\n\n\n<p>MaxSpareThreads\u306e\u5024\u306f\u5358\u7d14\u306b\u30b5\u30a4\u30c8\u306e\u898f\u6a21\u3092\u8003\u3048\u305f\u3089\u3001<br>MinSpareThreads\u306e2\u500d\u3067\u826f\u3055\u305d\u3046\u3068\u3044\u3046\u3053\u3068\u306750\u306b\u3059\u308b\u3002<\/p>\n\n\n\n<p>StartServer\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306f3\u306a\u306e\u3067\u3001\u3068\u308a\u3042\u3048\u305a\u30c7\u30d5\u30a9\u30eb\u30c8\u3088\u308a\u4f4e\u30442\u3068\u3059\u308b\u3002<\/p>\n\n\n\n<p>MaxConnectionsPerChild\u306fMinSpareThreads\u306e4\u500d\u306e100\u3068\u3059\u308b\u3002<\/p>\n\n\n\n<p>AsyncRequestWorkerFactor\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u306e2\u306e\u307e\u307e\u3068\u3059\u308b\u3002<\/p>\n\n\n\n<h2 id=\"toc8\" class=\"wp-block-heading\">\u6700\u5f8c\u306b<\/h2>\n\n\n\n<p>\u5f8c\u306f\u3053\u308c\u3089\u306e\u5024\u3092httpd.conf\u3067\u3001\u5404\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u3092\u4f7f\u3063\u3066\u8a2d\u5b9a\u3059\u308c\u3070\u826f\u3044\u3002<br>\u5c11\u306a\u304f\u3068\u3082\u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u3067\u306f\u30b5\u30fc\u30d0\u304c\u843d\u3061\u308b\u3053\u3068\u306f\u306a\u304b\u3063\u305f\u3057\u3001Failed request\u306e\u5024\u30820\u3060\u3063\u305f\u3002<br><pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ ab -n 200 -c 200 http:\/\/\u30c9\u30e1\u30a4\u30f3\u540d\/<\/pre><\/p>\n\n\n\n<p>\u305f\u3060\u3057\u3001\u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u3067\u306f\u30b5\u30fc\u30d0\u306f\u843d\u3061\u306a\u304b\u3063\u305f\u304c\u3001Failed request\u306e\u5024\u304c3\u306b\u306a\u3063\u3066\u3044\u305f\u3002<br><pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ ab -n 300 -c 300 http:\/\/\u30c9\u30e1\u30a4\u30f3\u540d\/<\/pre><\/p>\n\n\n\n<p>\u307e\u305f\u3001free\u30b3\u30de\u30f3\u30c9\u3067\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u3057\u305f\u3068\u3053\u308d\u3001<br>\u8ca0\u8377\u3092\u304b\u3051\u3066\u3044\u308b\u9593\u3001120MB\u307b\u3069\u672a\u4f7f\u7528\u30e1\u30e2\u30ea\u304c\u3042\u308b\u72b6\u614b\u3060\u3063\u305f\u3002<br>WordPress\u306e\u30b5\u30a4\u30c8\u3060\u3051\u3069\u30ad\u30e3\u30c3\u30b7\u30e5\u6a5f\u80fd\u3092\u4f7f\u3063\u3066\u3044\u306a\u3044\u72b6\u614b\u3067\u3053\u306e\u7d50\u679c\u306a\u306e\u3067\u3001<br>\u3057\u3070\u3089\u304f\u306f\u5927\u4e08\u592b\u3060\u308d\u3046\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3084\u308a\u305f\u3044\u3053\u3068 \u30b5\u30fc\u30d0\u304c\u91cd\u304f\u306a\u308b\u306e\u306f\u3057\u3087\u3046\u304c\u306a\u3044\u3068\u3057\u3066\u3001\u843d\u3061\u306a\u3044\u3088\u3046\u306b\u3057\u305f\u3044\u3002\u203b prefork MPM\u306e\u6642\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3060\u3068ab\u3092\u5229\u7528\u3057\u305f\u8ca0\u8377\u30c6\u30b9\u30c8\u3067Apache\u304c\u843d\u3061\u305f\u3051\u3069\u3001event MPM\u3060\u3068\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u72b6\u614b\u3067\u3001pr [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[32],"class_list":["post-834","post","type-post","status-publish","format-standard","hentry","category-apache","tag-apache"],"_links":{"self":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/834","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=834"}],"version-history":[{"count":8,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/834\/revisions"}],"predecessor-version":[{"id":842,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/834\/revisions\/842"}],"wp:attachment":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=834"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=834"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=834"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}