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

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

Related Articles

How to Restore Your cPanel Account: A Complete Guide for New System Administrators

This guide explains how new system administrators can restore a cPanel account using WHM, transfer accounts and configurations between servers, and enable diagnostic logging for transfer and restore operations. It covers essential concepts such as WHM vs. cPanel, root access, backup handling, SFTP uploads, transfer methods, and advanced debugging tools.

Continue

آموزش کامل انتقال تمام اکانت‌های cPanel از یک سرور به سرور دیگر

این مقاله نحوه انتقال همه اکانت‌های cPanel، تنظیمات سرویس‌ها، گواهی‌های SSL و IP اصلی سرور را از یک سرور قدیمی (Source) به یک سرور جدید (Target) توضیح می‌دهد. شامل نصب سرور جدید، انتقال تنظیمات، انتقال اکانت‌ها، تغییر IP، تنظیم DNS و نصب مجدد SSL است.

Continue

How to Migrate a WordPress® Installation to a cPanel & WHM Server

This guide explains how to migrate a WordPress installation from a macOS-hosted environment to a cPanel & WHM server. It covers exporting the database, uploading WordPress files, creating and importing a MySQL database, updating URLs, configuring wp-config.php, fixing broken links, and finalizing the migration.

Continue

How to Manually Transfer an Account Between Servers in cPanel & WHM

This article explains how to manually transfer a cPanel account between servers when the account is too large for WHM’s automated transfer tools. It covers creating temporary directories, compressing public_html and log files, securely transferring data with SCP, and restoring the files on the destination server.

Continue

How to Manually Migrate Horde Calendars and Contacts to Roundcube in cPanel & WHM

This article explains how to manually migrate Horde calendars and contacts to Roundcube in cPanel & WHM version 108 through 118. It covers exporting Horde data, placing it in the correct directories, and importing it into Roundcube using built‑in plugins or manual import tools.

Continue

How to Manually Migrate Accounts to cPanel & WHM from Unsupported Control Panels

This article explains how experienced system administrators can manually migrate accounts from unsupported third‑party control panels to cPanel & WHM. It covers pre‑migration steps, installation requirements, file and directory transfers, database restoration, SSL migration, and post‑migration tasks.

Continue