Insights

Moved to a Bigger VPS but Still Getting 503s? Check PHP-FPM pm.max_children

November 30, 2026
0:00
You upgraded from a 2 GB VPS to an 8 GB one, expecting 503 errors to disappear under traffic spikes. CPU and RAM graphs look calm, yet visitors still hit 503 Service Unavailable or 504 Gateway Timeout during busy hours. The hardware is not the bottleneck. PHP-FPM is. The problem is almost always pm.max_children. This directive caps how many PHP worker processes the pool can spawn. If you migrated from a small server and never touched the pool config, that cap followed you to the new machine. More RAM sitting idle does not matter when PHP-FPM refuses to start more workers than the old limit allows.
A 503 from Nginx, Apache, or LiteSpeed in front of PHP-FPM typically means the web server tried to hand a request to the PHP backend and got no response in time. The web server is fine. PHP-FPM is the one choking. When every PHP-FPM worker is busy and a new request arrives, it sits in a backlog queue. If the queue fills up or the web server's proxy timeout expires before a worker frees up, the visitor gets a 503 or 504. The distinction between 503 and 504 depends on which timeout fires first and how the web server is configured, but the root cause is the same: not enough PHP workers to handle concurrent requests. A common red herring at this stage is blaming the web server timeout. Raising proxy_read_timeout in Nginx or ProxyTimeout in Apache only delays the error; it does not fix the starvation. If you are also seeing 504s after raising max_execution_time in PHP but not the corresponding web server timeout, that is a separate but related issue covered in Raised max_execution_time but Still Getting 504? Match Nginx fastcgi_read_timeout.
PHP-FPM writes a specific warning when it hits the worker ceiling. The exact log path depends on your distro and control panel, but common locations include /var/log/php-fpm/www-error.log, /var/log/php8.x-fpm.log, or a path under /opt/ if you use cPanel's EA4 PHP packages. Check your pool config file for the error_log directive if you are unsure. Search for this message:
BASH
grep 'max_children' /var/log/php-fpm/www-error.log
Sample output format:
TEXT
[25-Jun-2025 14:03:11] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it
That single line confirms the diagnosis. PHP-FPM hit its worker limit and could not spawn more processes to handle incoming requests. Everything after that is queue pressure. If you see this message repeating during the same time windows your monitoring shows 503s, you have your root cause. No need to look further at disk I/O, MySQL, or network. For a deeper walkthrough on reading these logs and distinguishing max_children saturation from other PHP-FPM failures, see Reading PHP-FPM Logs to Confirm max_children Is Causing Your 502 Errors.
When you migrate a VPS, the PHP-FPM pool configuration file typically comes along. On most setups this lives at /etc/php/8.x/fpm/pool.d/www.conf (Debian/Ubuntu) or /etc/php-fpm.d/www.conf (CentOS/AlmaLinux). If you used a control panel migration tool or a full disk image, the file transferred unchanged. The key directives inside that file:
  • pm = dynamic — the process manager mode. Dynamic means PHP-FPM starts some workers at boot and spawns more on demand, up to a hard ceiling.
  • pm.max_children = 5 — that hard ceiling. On a 2 GB server, 5 might have been reasonable. On an 8 GB server, it wastes most of your RAM.
  • pm.start_servers, pm.min_spare_servers, pm.max_spare_servers — these control how many idle workers PHP-FPM keeps around, but none of them can exceed max_children.
The upgrade gave you four times the memory. The pool config still says "never run more than 5 workers." That is the mismatch.
Do not guess. Measure how much RAM each PHP-FPM worker actually uses on your server, then divide. While the site is under normal traffic (not idle, not during a spike), run:
BASH
ps --no-headers -o rss -C php-fpm | awk '{ sum += $1; n++ } END { print "Workers: " n; print "Avg RSS (KB): " sum/n; print "Avg RSS (MB): " sum/n/1024 }'
This prints the number of active PHP-FPM workers and their average RSS (Resident Set Size — the actual physical memory each process occupies). RSS is what matters here, not the virtual memory column. A WordPress site with a moderate plugin stack often lands somewhere around 30 to 60 MB per worker, but this varies enormously. A lean static-content site might use 20 MB. A site running WooCommerce with page builders can push past 80 MB. Measure yours; do not assume. Once you have the average, the formula is straightforward: max_children = RAM available for PHP-FPM / average RSS per worker "RAM available for PHP-FPM" is not your total server RAM. Subtract what the OS, the web server, MySQL or MariaDB, and any other services need. As an illustrative example: on an 8 GB VPS where the OS, web server, and database together consume roughly 3 GB, you have about 5 GB left for PHP-FPM. If each worker uses 50 MB on average, that gives you 5000 / 50 = 100 as a theoretical ceiling. In practice, leave headroom. Setting max_children to exactly the theoretical limit means any memory spike in a single worker risks triggering the OOM killer, which is worse than a 503. A rule of thumb is to use 70 to 80 percent of the theoretical number. In this illustrative example, 70 to 80 workers would be a safer starting point.
Open your pool config file (path depends on your setup) and update pm.max_children. If you are using pm = dynamic, also adjust the related directives so they make sense relative to the new ceiling:
  • pm.start_servers — typically set to 25 percent of max_children.
  • pm.min_spare_servers — a small number, enough to handle idle-period requests without delay.
  • pm.max_spare_servers — typically set to 75 percent of max_children, or equal to start_servers.
These are starting points, not universal rules. The right values depend on your traffic pattern. After saving the file, reload PHP-FPM. On systemd-based systems:
BASH
systemctl reload php8.2-fpm
Replace php8.2-fpm with whatever service name matches your PHP version. Use systemctl list-units | grep fpm if you are unsure. Reload, not restart. A reload lets PHP-FPM finish serving current requests before applying the new config. A restart kills active workers immediately. After reloading, verify the new setting took effect by checking the process count under load and watching the FPM log for the max_children warning. If the warning stops appearing during traffic that previously triggered it, the fix is working.
It is tempting to set max_children to a very large number and forget about it. That backfires. If you allow more workers than your RAM can support, the server runs out of memory, the kernel's OOM killer starts terminating processes (often MySQL, which is typically the largest single consumer), and the site goes down harder than a 503 ever would. The goal is not "as many workers as possible." The goal is "as many workers as the server can sustain without memory pressure." That is why measuring per-process RSS matters more than picking a number from a blog post.
PHP-FPM worker memory is not static. Installing new WordPress plugins, updating PHP versions, or enabling opcache all change per-process RSS. A value you calculated today might be wrong in three months. Periodically re-run the RSS measurement command and compare it against your max_children setting. If average worker memory grew from 50 MB to 70 MB but max_children stayed the same, you are now overcommitting RAM and heading toward OOM territory. The short version: every time you upgrade hardware, migrate a server, or make significant application changes, re-check pm.max_children. The number is not a set-and-forget value. It is a function of your current RAM and your current per-process memory use. Change either input, and the output needs to change too.

Join My Newsletter & Get Updates!

Get notified whenever a new technical guide, server infrastructure breakdown, or personal reflection goes live, plus a curated weekly digest.