~3 min read • Updated Feb 15, 2026
Apache vs. PHP-FPM Bottleneck with Child Processes
Last modified: March 11, 2021
Overview
Apache servers that use the prefork MPM with fewer server instances than the maximum number of PHP-FPM child processes may experience serious performance issues. This happens when Apache cannot feed enough concurrent requests to PHP-FPM, creating a bottleneck.
The Issue
In this scenario, the PHP-FPM configuration allows a maximum of 20 child processes, while Apache only allows 5 server instances.
Example PHP-FPM configuration:
pm_max_children: 20
pm_max_requests: 20
Example Apache prefork configuration:
StartServers: 5
<IfModule prefork.c>
MinSpareServers: 10
MaxSpareServers: 10
</IfModule>
If Apache receives 20 requests, it can only process a limited number concurrently due to its low number of server instances. Requests are queued and passed to PHP-FPM in batches, which leads to delays and degraded performance.
Warning: On high-traffic servers, this configuration can cause severe performance degradation.
The Solution
To resolve this issue, you must configure Apache to allow enough server instances to match or exceed the maximum number of PHP-FPM child processes.
In WHM, navigate to:
WHM » Home » Service Configuration » Global Configuration
Set the following options to values greater than or equal to pm_max_children in your PHP-FPM configuration:
- Minimum Spare Servers
- Maximum Spare Servers
- Max Request Workers
Configuration Values of PHP-FPM
Last modified: December 5, 2023
Overview
This section lists PHP-FPM configuration directives and their default values, and explains how to add or override them using YAML configuration files in cPanel & WHM.
Warning: Only enable Apache PHP-FPM if your server has at least 2 GB of RAM, or at least 30 MB of RAM per domain. Otherwise, your server may experience severe performance issues.
Global Directives
Global directives are defined in /var/cpanel/ApachePHPFPM/system.yaml. When editing this file, you must normalize periods . to underscores _ in key names.
| Key | Name | Default |
|---|---|---|
| daemonize | daemonize | no |
| emergency_restart_interval | emergency_restart_interval | 0 |
| emergency_restart_threshold | emergency_restart_threshold | 0 |
| error_log | error_log | /opt/cpanel/[% ea_php_version %]/root/usr/var/log/php-fpm/error.log |
| log_level | log_level | notice |
| pid | pid | /opt/cpanel/[% ea_php_version %]/root/usr/var/run/php-fpm/php-fpm.pid |
| process_control_timeout | process_control_timeout | 10 |
Caution: Incorrect YAML syntax can cause services to fail. Always back up configuration files before editing.
Pool Name Directives
PHP-FPM pools allow each domain or application to run under its own user. Pool defaults are defined in /var/cpanel/ApachePHPFPM/system_pool_defaults.yaml.
| Key | Name | Default |
|---|---|---|
| catch_workers_output | catch_workers_output | yes |
| chdir | chdir | [% homedir %] |
| group | group | nobody |
| listen | listen | "[% socket_path %]" |
| listen_mode | listen.mode | 0660 |
| pm | pm | ondemand |
| pm_max_children | pm.max_children | 5 |
| pm_max_requests | pm.max_requests | 20 |
| pm_process_idle_timeout | pm.process_idle_timeout | 10 |
| user | user | "[% username %]" |
YAML Syntax Rules
- Use single quotes
' 'around strings that contain double quotes" ". - Escape double quotes inside strings with
\. - Key names must only contain letters, numbers, and underscores.
Add a Value to the Configuration
Example of a complete directive line:
php_value_open_basedir: { name: 'php_value[open_basedir]', value: "[% documentroot %]" }
Add an Unknown Value
To add a value that is not provided by default:
php_admin_value_ldap_max_links: { name: 'php_admin_value[ldap.max_links]', value: -1 }
Important: If you use php_value or php_flag, these settings will override any php.ini values set in the user’s .htaccess files.
Conclusion
Properly aligning Apache prefork settings with PHP-FPM child process limits is critical to avoiding performance bottlenecks. Combined with a solid understanding of PHP-FPM configuration directives and safe YAML editing practices, this ensures stable and efficient PHP hosting on cPanel & WHM servers.
Written & researched by Dr. Shahin Siami