Skip to content

Sizing a PHP-FPM pool on cPanel from real memory measurement

A practical method for sizing PHP-FPM pm.max_children, pm.start_servers, and pm.min/max_spare_servers on a cPanel server, based on actual per-process memory usage rather than the defaults.

cPanel ships PHP-FPM with pm = ondemand and pm.max_children = 5 by default — workable for a quiet account but the wrong shape for any site under real traffic. Sized too low and requests queue inside FPM until the proxy timeout fires. Sized too high and a traffic spike OOMs the box. The right number is not a guess; it is (available RAM for PHP) / (average per-process RSS).

What’s happening

PHP-FPM under cPanel runs one pool per account (and optionally per domain). Each pool has its own pm.max_children cap. When all children for a pool are busy, new requests for that pool sit in a per-pool queue until request_terminate_timeout or ProxyTimeout fires. Memory consumption per child depends on the application: a vanilla WordPress sits at 30–60 MB RSS; a WooCommerce admin can reach 200 MB; a Magento worker easily exceeds 300 MB.

How to verify

Measure per-process memory for the account’s pool:

ps -o pid,user,rss,cmd -C php-fpm | grep <user> | sort -k3 -n
cat /opt/cpanel/ea-php82/root/etc/php-fpm.d/<user>+<domain>.conf | grep -E "pm\."
free -h
systemctl status ea-php82-php-fpm | head

The rss column is what each worker actually consumes after warmup. Take the 90th percentile, not the mean.

The fix

  1. Measure during a realistic 15-minute window. Note the 90th-percentile RSS of children for the pool. Call it M.
  2. Decide how much RAM you are willing to allocate to this pool. On a dedicated host for one customer, that might be total_ram - 4GB. On a shared host, divide the available pool budget by the number of busy accounts.
  3. pm.max_children = available_pool_ram / M. Round down. For a 4 GB pool budget with 150 MB children, that is 26.
  4. Edit /opt/cpanel/ea-php82/root/etc/php-fpm.d/<user>+<domain>.conf (or the MultiPHP Manager > FPM Settings UI for the account):
    pm = dynamic
    pm.max_children = 26
    pm.start_servers = 6
    pm.min_spare_servers = 4
    pm.max_spare_servers = 10
    pm.max_requests = 500
  5. Reload the FPM pool: systemctl reload ea-php82-php-fpm.
  6. Watch for an hour. Confirm queue depth stays at zero with tail -f /opt/cpanel/ea-php82/root/usr/var/log/php-fpm.log looking for pool ... seems busy warnings. Confirm worker count plateaus, does not hit the ceiling under normal load.
  7. If memory measurement showed a long tail (the 99th percentile is 3x the 90th), set pm.max_requests = 250 lower so leaked memory is recycled more often.

For environments where pool sizing needs to be revisited as traffic shifts, Stack Harbor measures and resizes pools as part of environment management.