A single pool is straightforward to size. A cPanel server with 60 PHP-FPM pools — one per account — needs a different calculation: the sum of pm.max_children across every pool can theoretically exceed the box’s RAM by 5x without anyone noticing, until the day all 60 accounts hit a traffic peak at the same minute. The fix is a server-level budget that the per-pool caps must fit inside.
What’s happening
pm.max_children is a per-pool ceiling, not a global one. cPanel does not enforce a global PHP worker count; nothing stops you from setting max_children = 50 on every one of 60 pools and ending up at 3000 worker slots on a 32 GB box. Most of the time it does not bite because pools are not all busy together. But statistically, the more pools you have, the higher the probability some subset spikes at once, and that is when you discover the budget you never set.
How to verify
Sum the configured ceiling and the active count:
grep -r "pm.max_children" /opt/cpanel/ea-php*/root/etc/php-fpm.d/ | awk '{sum+=$NF} END {print sum}'
ps -C php-fpm --no-headers | wc -l
free -h
ps -o rss,cmd -C php-fpm | awk '{sum+=$1} END {print sum/1024 " MB"}'
cat /proc/meminfo | grep -E "MemTotal|MemAvailable"
The first number is the theoretical maximum if every pool went fully busy at once. The second is the current population. The third and last give you the budget.
The fix
- Establish the budget. Pick the fraction of host RAM you want to commit to PHP workers — usually 50–70% on a host where MySQL and Apache also live. On a 32 GB host, that is 16–22 GB for PHP.
- Measure average per-worker RSS across pools (say 80 MB). The global ceiling is
budget / avg_RSS. For 16 GB / 80 MB = 200 worker slots. - Allocate per-pool. Most pools get a small
pm.max_children(10), the busy ones get 30. Add the per-pool ceilings; the sum must not exceed the global ceiling. - For each pool, edit
/opt/cpanel/ea-php82/root/etc/php-fpm.d/<user>+<domain>.conf(or use MultiPHP Manager > FPM Settings). - Reload affected FPM services:
for v in 80 81 82 83 84; do systemctl reload ea-php${v}-php-fpm 2>/dev/null; done. - Set up a monitor that alerts when
ps -C php-fpm --no-headers | wc -lexceeds 80% of the global ceiling. That is your early warning before the next quiet pool wakes up and tips the box over. - Reassess quarterly. Customer traffic shifts; pools that were small a year ago may now be the busiest on the box.
For environments where dozens of FPM pools share one host, Stack Harbor maintains a per-host worker budget under environment management.