Short answer: Enter the server’s RAM, the memory to keep for everything else and the average size of a PHP-FPM worker. The calculator divides the remaining RAM by the worker size to get pm.max_children, splits it across your pools, and suggests pm.start_servers, pm.min_spare_servers and pm.max_spare_servers, with the files and commands to apply them on cPanel, DirectAdmin and plain Linux.
Built and tested in Chromium on 6 Oct 2026; runs entirely in your browser.
Table of Contents
How to use the PHP-FPM calculator
- Enter total RAM in GB (0.5 for 512 MB).
- Enter RAM to keep for the OS, MariaDB or MySQL, Redis and the web server. Leave it blank to reserve 25%.
- Measure the average worker size on the server (command below) and enter it in MB. Blank uses 64 MB.
- Enter how many pools share the server. On cPanel every domain has its own pool; on DirectAdmin every user does.
- Pick the process manager and press Calculate.
Measure the worker size while the sites are busy. This command averages the resident memory of all PHP-FPM workers and skips the master processes; we ran it on our DirectAdmin 1.712 lab server:
ps --no-headers -o rss,cmd -C php-fpm | grep -v "master process" | awk '{s+=$1;n++} END {if(n) printf "%d workers, average %.0f MB\n", n, s/n/1024}'
What the output means
| Setting | How it is worked out |
|---|---|
pm.max_children | (total RAM − reserved RAM) ÷ worker size, divided evenly between pools. The hard limit on workers per pool. |
pm.min_spare_servers / pm.max_spare_servers | 25% and 75% of max_children: a common starting point for pm = dynamic, not a rule. |
pm.start_servers | PHP’s own default formula: min_spare + (max_spare − min_spare) ÷ 2. |
pm.process_idle_timeout | For ondemand: seconds an idle worker lives (10). |
pm.max_requests | 500: workers are replaced after 500 requests to limit memory leaks. |
PHP-FPM refuses to start a pool if the spare-server values are larger than max_children or if start_servers is outside the min/max spare range; the calculator always produces values that pass those checks.
Examples
An 8 GB server, 2 GB reserved, 64 MB workers, one pool, pm = dynamic:
pm = dynamic
pm.max_children = 96
pm.start_servers = 48
pm.min_spare_servers = 24
pm.max_spare_servers = 72
pm.max_requests = 500
On cPanel, per-domain values go in /var/cpanel/userdata/USER/DOMAIN.php-fpm.yaml with dots replaced by underscores (pm_max_children: 96), followed by /scripts/php_fpm_config --rebuild --domain=DOMAIN. Server-wide defaults are in /var/cpanel/ApachePHPFPM/system_pool_defaults.yaml or WHM’s MultiPHP Manager. cPanel’s own defaults are pm = ondemand, max_children 5 and max_requests 20.
On DirectAdmin the generated pools live in /usr/local/directadmin/data/users/USER/php/php-fpmXX.conf. Change the default with da config-set php_fpm_max_children_default 20 and da build rewrite_confs; for other settings copy the template to /usr/local/directadmin/data/templates/custom/php-fpm.conf. Our DirectAdmin lab uses pm = ondemand with max_children 10 by default.
Common mistakes
- Using the worker size from an idle server. Workers grow as they serve requests. Measure during busy hours.
- Forgetting the database. MariaDB’s buffer pool usually needs more RAM than PHP. Reserve it first.
- Giving every pool the full total. 30 sites with max_children 20 each can start 600 workers. Split the total and give busy sites more.
- Editing cPanel’s generated .conf files. They are rebuilt from the YAML files; edit the YAML instead.
- Raising max_children to hide slow code. If “server reached pm.max_children setting” keeps appearing, find the slow requests with the PHP-FPM slow log analyzer first.
Official documentation: PHP manual: FPM configuration · cPanel: configuration values of PHP-FPM
Related: cPanel PHP-FPM Tuning: Sizing pm.max_children and OPcache · DirectAdmin 503 PHP-FPM Errors: Log Checks · PHP-FPM Slow Log Analyzer · High Load cPanel Server: Find the Culprit Fast (5 Tools) · AI Config Generator for Nginx, Apache, PHP-FPM and MariaDB
See also: LiteSpeed vs OpenLiteSpeed for Hosting Servers: Which to Pick · Install OpenLiteSpeed and WordPress on AlmaLinux 10 (No Panel) · Stuck lsphp Processes on cPanel LiteSpeed: Diagnose and Kill Safely
Frequently asked questions
How do I calculate pm.max_children?
Subtract the RAM needed by the OS, database and other services from total RAM, then divide by the average PHP-FPM worker size. Split the result between pools if several sites share the server.
Should I use dynamic, ondemand or static?
ondemand saves memory on servers with many quiet sites and is the cPanel and DirectAdmin default. dynamic keeps some workers ready for busier sites. static suits a dedicated server running one busy application.
How do I find the average PHP-FPM process size?
Run the ps command on this page while the sites are busy. It averages the resident memory of the worker processes.
Why does the result look conservative?
Resident memory counts shared memory such as OPcache in every worker, so the average overstates real use. That leaves a safety margin.
Where do I see that max_children was reached?
In the PHP-FPM error log, as “server reached pm.max_children setting”. On cPanel that is /opt/cpanel/ea-phpXX/root/usr/var/log/php-fpm/error.log; DirectAdmin logs to syslog, so check journalctl.