Apache vs PHP-FPM Bottlenecks with Child Processes and PHP-FPM Configuration Basics

This article explains how performance bottlenecks can occur when Apache’s prefork MPM is misaligned with PHP-FPM child process limits, and how to fix them by tuning Apache worker settings. It also provides an overview of key PHP-FPM configuration directives, their defaults, and how to safely customize them using YAML configuration files in cPanel & WHM.

apache php-fpm performancephp-fpm configuration cpanelprefork mpm bottleneck

~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.

KeyNameDefault
daemonizedaemonizeno
emergency_restart_intervalemergency_restart_interval0
emergency_restart_thresholdemergency_restart_threshold0
error_logerror_log/opt/cpanel/[% ea_php_version %]/root/usr/var/log/php-fpm/error.log
log_levellog_levelnotice
pidpid/opt/cpanel/[% ea_php_version %]/root/usr/var/run/php-fpm/php-fpm.pid
process_control_timeoutprocess_control_timeout10

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.

KeyNameDefault
catch_workers_outputcatch_workers_outputyes
chdirchdir[% homedir %]
groupgroupnobody
listenlisten"[% socket_path %]"
listen_modelisten.mode0660
pmpmondemand
pm_max_childrenpm.max_children5
pm_max_requestspm.max_requests20
pm_process_idle_timeoutpm.process_idle_timeout10
useruser"[% 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