
The pm.max_children parameter in PHP-FPM defines the maximum number of simultaneous PHP processes. If set too low, it restricts concurrency and slows response times; if set too high, it risks memory exhaustion. Proper tuning is crucial for maintaining stable and efficient server performance.
In this guide, we’ll break down how to properly set pm.max_children for best server performance, including step-by-step instructions for manual setup and using ServerAvatar.
What is PHP-FPM?
PHP-FPM (PHP FastCGI Process Manager) is the engine that runs your PHP code in a more efficient way. It works as a pool of PHP processes waiting to handle incoming requests from your web server (Nginx or Apache).
Without PHP-FPM, every request would be slow and resource-hungry. With it, your site handles more traffic smoothly.
Understanding pm.max_children
The pm.max_children setting defines how many PHP processes can exist simultaneously.
- If you set it too low, your server will reject new requests once all processes are busy.
- If you set it too high, your server may run out of memory and crash.
By default, this value is often set conservatively, which may not fit your server resources.
Why pm.max_children is Critical
This parameter directly controls:
- Concurrency: More processes = more simultaneous visitors.
- Memory Usage: Each PHP process consumes RAM.
- Server Stability: Prevents overload by limiting processes.
Think of it like having the right number of checkout counters at a supermarket — not too few to cause long lines, not too many to waste resources.
How to Calculate pm.max_children
Here’s the general formula:
pm.max_children = Total RAM available for PHP / Average PHP process size
Step 1: Find memory per PHP process. Run:
ps -ylC php-fpm --sort:rss
Look at the RSS (resident set size) column — that’s the memory usage per process.
Step 2: Estimate. If each process uses ~50MB and you have 2GB (2000MB) RAM available:
2000MB / 50MB = 40
So pm.max_children = 40.
ServerAvatar Method: step-by-step guide
What is ServerAvatar
ServerAvatar is a managed cloud hosting provider that simplifies the deployment, management, and monitoring of servers and applications, no deep technical expertise required.
with ServerAvatar you can:-
- Deploy servers directly on top cloud providers like DigitalOcean, Vultr, Hetzner (Linode coming soon).
- No need for your own cloud provider account.
- Easily deploy and manage apps like WordPress, Laravel, n8n, custom PHP, and Node.js.
- Enjoy one-click deployments for faster setup.
- Access features like monitoring, backups, free auto-renewing SSL, firewall, fail2ban, and more to simplify daily tasks.
- Supports various stacks: LAMP, LEMP, OLS, and Node Stack.
- Comes with a built-in log monitoring suite.
- Get 24/7 expert technical support.
- Enjoy affordable, scalable pricing plans.
ServerAvatar makes this whole process point-and-click easy:
- Login to ServerAvatar Panel.
- Go to Server Dashboard then navigate to server.
- Click on Application then Select your application.

- Navigate to PHP Settings
- Go to PHP process manager section and Locate max_children.
- Enter your calculated value for example 40.

Click Save & Restart Services.
- Navigate to your appropriate Server Panel >> Services section.
- Restart your web server service by clicking on the “Reload” icon to apply new settings.

ServerAvatar will automatically update the PHP configuration, and the change takes effect immediately. This method is very easy and ideal for beginners or anyone who wants a fast, error-free way to manage PHP settings without touching the command line.

Manually: Step-by-Step: Setting pm.max_children
Open the PHP-FPM config file:
sudo nano /etc/php/8.1/fpm/pool.d/www.conf
Search for:
pm.max_children
Update with your calculated value.
Save and exit (CTRL+O, CTRL+X).
Restart PHP-FPM:
<br>sudo systemctl restart php8.1-fpm
Advanced PHP-FPM Parameters
Along with pm.max_children, you should also check:
- pm.start_servers – Number of processes started initially.
- pm.min_spare_servers – Minimum idle processes.
- pm.max_spare_servers – Maximum idle processes.
These ensure flexibility in handling fluctuating traffic.
Optimizing for Different Server Sizes
- Small Servers (1–2GB RAM): Set pm.max_children around 10–20.
- Medium Servers (4–8GB RAM): Set around 30–60.
- Large Servers (16+GB RAM): Can handle 100+ processes, depending on site load.
Monitoring PHP-FPM Performance
To see if your setting works well:
- Run top or htop to monitor CPU & RAM.
- Check error logs at /var/log/php8.1-fpm.log.
- Look for errors like “server reached pm.max_children”, which means you need to increase it.
Common Mistakes to Avoid
- Setting values too high and exhausting RAM.
- Forgetting to adjust related parameters.
- Not restarting PHP-FPM after changes.
Practical Example: Manual Configuration
If your server has 4GB RAM and each PHP process uses ~70MB:
4000MB / 70MB ≈ 57
So you should set pm.max_children = 55–60.
Performance Testing After Changes
Once applied, run tests:
ApacheBench (ab):
ab -n 1000 -c 50 http://yourdomain.com/
Siege:
siege -c 50 -t30S http://yourdomain.com/
Compare results before and after tuning pm.max_children.
Best Practices for Long-Term Stability
- Regularly monitor logs and resource usage.
- Scale server size as traffic grows.
- Use caching (Redis, Memcached) and a CDN for best performance.
Conclusion
Setting PHP-FPM pm.max_children is one of the most effective ways to optimize server performance. By calculating based on available RAM and monitoring results, you can find the sweet spot where your site runs fast without overloading your server.
For beginners, ServerAvatar simplifies this process into a few clicks, making it the safest way to optimize PHP-FPM without touching config files.
FAQs
What happens if pm.max_children is too low?
Your server will start rejecting requests when traffic spikes, causing slowdowns or errors.
How do I know the best value for my server?
Measure memory usage per PHP process, apply the formula, and adjust based on logs.
Can ServerAvatar auto-tune pm.max_children?
While it doesn’t auto-tune, ServerAvatar makes it easy to manually optimize and adjust.
Do I need to restart PHP-FPM after changing it?
Yes, changes only take effect after restarting PHP-FPM service.
Is pm.max_children different for Nginx and Apache setups?
No, the parameter works the same way for both — it only depends on PHP-FPM.