Apache vs. PHP-FPM Bottleneck with Child Processes
Last modified: March 11, 2021
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.
This issue and solution only apply to servers that run Apache’s
In the following scenario, the PHP-FPM server’s configuration allows a maximum of 20 PHP-FPM child processes and the Apache server’s configuration allows five server instances.
The following example represents the PHP-FPM server’s configuration file:
The following example represents the Apache server’s configuration file:
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.
For high-volume servers, this configuration can cause severe performance issues.
To solve this issue, you must 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’s Global Configuration interface (WHM >> Home >> Service Configuration >> Global Configuration):
Minimum Spare Servers
Maximum Spare Servers
Max Request Workers
Set these options to a value greater than or equal to the
pm_max_children setting in the PHP-FPM server’s configuration file.