{"id":796,"date":"2021-07-23T12:38:22","date_gmt":"2021-07-23T12:38:22","guid":{"rendered":"https:\/\/ssdsunucum.com\/blog\/apache-vs-php-fpm-bottleneck-with-child-processes\/"},"modified":"2021-07-23T12:38:22","modified_gmt":"2021-07-23T12:38:22","slug":"apache-vs-php-fpm-bottleneck-with-child-processes","status":"publish","type":"post","link":"https:\/\/ssdsunucum.com\/blog\/apache-vs-php-fpm-bottleneck-with-child-processes\/","title":{"rendered":"Apache vs. PHP-FPM Bottleneck with Child Processes"},"content":{"rendered":"<\/p>\n<div class=\"col-md-9\">\n<div class=\"flex-column flex-md-row article-header\"><\/div>\n<hr>\n<h2 id=\"overview\">Overview<\/h2>\n<p>Apache servers that use the <code>prefork<\/code> MPM with fewer server instances than the maximum number of PHP-FPM child processes may experience performance issues. This document explains how to resolve these dependency issues.<\/p>\n<div class=\"callout callout-warning\">\n<div class=\"callout-heading\">Important:<\/div>\n<div class=\"callout-content\">\n<p>This issue and solution <strong>only<\/strong> apply to servers that run Apache\u2019s <code>prefork<\/code> MPM.<\/p>\n<\/p><\/div>\n<\/div>\n<h2 id=\"the-issue\">The issue<\/h2>\n<p>In the following scenario, the PHP-FPM server\u2019s configuration allows a maximum of 20 PHP-FPM child processes and the Apache server\u2019s configuration allows five server instances.<\/p>\n<p>The following example represents the PHP-FPM server\u2019s configuration file:<\/p>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-BASH\" data-lang=\"BASH\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">3\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-BASH\" data-lang=\"BASH\">_is_present: <span style=\"color:#ae81ff\">1<\/span>\npm_max_children: <span style=\"color:#ae81ff\">20<\/span>\npm_max_requests: <span style=\"color:#ae81ff\">20<\/span><\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<p>The following example represents the Apache server\u2019s configuration file:<\/p>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-BASH\" data-lang=\"BASH\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">3\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">4\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">5\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-BASH\" data-lang=\"BASH\">StartServers: <span style=\"color:#ae81ff\">5<\/span>\n&lt;IfModule prefork.c&gt;\nMinSpareServers: <span style=\"color:#ae81ff\">10<\/span>\nMaxSpareServers: <span style=\"color:#ae81ff\">10<\/span>\n&lt;\/IfModule&gt;<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<p>If the Apache server receives 20 requests, it immediately passes ten of those requests to the available PHP-FPM child processes. After PHP-FPM processes those requests, Apache will pass another ten requests to PHP-FPM.<\/p>\n<div class=\"callout callout-danger\">\n<div class=\"callout-heading\">Warning:<\/div>\n<div class=\"callout-content\">\n<p>For high-volume servers, this configuration can cause severe performance issues.<\/p>\n<\/p><\/div>\n<\/div>\n<h2 id=\"the-solution\">The solution<\/h2>\n<p>To solve this issue, you <strong>must<\/strong> configure Apache to allow enough server instances to handle the maximum number of PHP-FPM child processes. To do this, configure the following options in WHM\u2019s <em>Global Configuration<\/em> interface (<em>WHM &gt;&gt; Home &gt;&gt; Service Configuration &gt;&gt; Global Configuration<\/em>):<\/p>\n<ul>\n<li>\n<p><em>Minimum Spare Servers<\/em><\/p>\n<\/li>\n<li>\n<p><em>Maximum Spare Servers<\/em><\/p>\n<\/li>\n<li>\n<p><em>Max Request Workers<\/em><\/p>\n<\/li>\n<\/ul>\n<p>Set these options to a value greater than or equal to the <code>pm_max_children<\/code> setting in the PHP-FPM server\u2019s configuration file.<\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Overview Apache servers that use the prefork MPM with fewer server instances than the maximum number of PHP-FPM child processes may experience performance issues. This document explains how to resolve these dependency issues. Important: This issue and solution only apply to servers that run Apache\u2019s prefork MPM. The issue In the following scenario, the PHP-FPM &hellip;<\/p>\n","protected":false},"author":1,"featured_media":797,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/796"}],"collection":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/comments?post=796"}],"version-history":[{"count":0,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/796\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media\/797"}],"wp:attachment":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media?parent=796"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/categories?post=796"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/tags?post=796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}