DEV Community

Cover image for How to Set PHP-FPM pm.max_children for Best Server Performance
Dishang Soni for ServerAvatar

Posted on • Originally published at serveravatar.com

How to Set PHP-FPM pm.max_children for Best Server Performance

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.

How to Set PHP-FPM pm.max_children for Best Server Performance - ServerAvatar

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

How to Set PHP-FPM pm.max_children for Best Server Performance - ServerAvatar

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.

How to Set PHP-FPM pm.max_children for Best Server Performance - ServerAvatar

Read Full Article:-

Top comments (0)