Insights

Thinking More PHP-FPM Workers Means Faster Sites? Oversized Pools Cause 503s Instead

November 20, 2026
0:00
A site throws 502 or 503 errors under traffic. Someone checks PHP-FPM logs, sees the max_children warning, and cranks the number up — from 10 to 50, maybe 100. More workers, more requests handled simultaneously, faster site. Sounds logical. Except on a server with limited RAM, this is exactly how you turn intermittent slowness into a hard outage.
PHP-FPM (FastCGI Process Manager) handles PHP requests through worker processes. Each worker handles one request at a time. When all workers are busy and a new request arrives, it queues. If the queue is full, the web server (Nginx, LiteSpeed, Apache) gets no response and returns a 502 or 503 to the visitor. So raising pm.max_children seems like the obvious fix: more workers, shorter queue, fewer errors. The part people miss is that each worker is a separate process that consumes real memory. A bare PHP process might use 20-30 MB. Load WordPress with WooCommerce, a page builder, and a handful of plugins, and each worker can easily consume 60-80 MB or more. Do the math on a 2 GB VPS. The OS and services (MySQL, web server, mail) typically need 600-800 MB. That leaves roughly 1.2 GB for PHP-FPM. If each worker uses 60 MB, you can fit about 20 workers before RAM runs out. Set max_children to 50 and you are asking for 3 GB of PHP-FPM memory on a box that has 2 GB total. What happens next: the Linux kernel's OOM (Out of Memory) killer starts terminating processes. Sometimes it kills a PHP-FPM worker. Sometimes it kills MySQL. Sometimes it kills the master PHP-FPM process itself. The result is not a slow site — it is a dead one. Every request returns 502 or 503 until someone restarts services or the box reboots.
Guessing worker memory is unreliable. Measure it on your running server. SSH in and 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 — actual physical memory used). Run this during normal traffic, not on an idle server. Idle workers use less memory than workers actively serving WordPress pages. Sample output format:
TEXT
Workers: 12
Avg RSS (KB): 61440
Avg RSS (MB): 60
That tells you each worker uses about 60 MB on average under real load.
Once you know per-worker memory, the calculation is straightforward: max_children = Available RAM for PHP-FPM / Average worker memory "Available RAM for PHP-FPM" means total server RAM minus what the OS, database, web server, and other services need. On a dedicated PHP application server, most RAM is available. On a typical VPS running everything (web server, MySQL, PHP-FPM, maybe Redis), you need to subtract those. Check current memory usage with free -m. Look at the "available" column — that is what the kernel considers actually free for new allocations. But do not give all of it to PHP-FPM. Leave a buffer (at least 10-15% of total RAM) so the OS has room for disk cache and spikes. Illustrative example on a 4 GB VPS:
  • Total RAM: 4096 MB
  • OS + MySQL + web server: ~1200 MB
  • Safety buffer (~15%): ~600 MB
  • Available for PHP-FPM: ~2300 MB
  • Average worker RSS: 60 MB
  • max_children: 2300 / 60 ≈ 38
Setting max_children to 38 keeps the server within its memory budget. Setting it to 100 would request 6000 MB of PHP-FPM memory alone — guaranteed OOM.
The pm directive in your pool config controls how PHP-FPM spawns and manages workers. The pool config file is typically at /etc/php/<version>/fpm/pool.d/www.conf on Debian/Ubuntu systems, though the path varies by distro and PHP version. Three modes exist: pm = static — Spawns exactly pm.max_children workers at startup. They stay alive permanently. No spawn/kill overhead per request. Best when the server is dedicated to PHP and you want predictable memory usage. Downside: those workers consume RAM even when idle at 3 AM. pm = dynamic — Starts with pm.start_servers workers, scales up to pm.max_children under load, and kills idle workers down to pm.min_spare_servers. Most common default. Good for servers that handle variable traffic. The key settings:
INI
pm = dynamic
pm.max_children = 38
pm.start_servers = 8
pm.min_spare_servers = 4
pm.max_spare_servers = 12
pm = ondemand — No workers running when idle. Spawns a worker only when a request arrives, kills it after pm.process_idle_timeout seconds of inactivity. Lowest memory usage at rest. Downside: first request after idle pays a spawn penalty (typically tens of milliseconds). Useful on servers hosting many low-traffic sites where you cannot afford idle workers for each pool. For most single-site VPS setups, dynamic works well. The critical part is not which mode you pick — it is that pm.max_children stays within your RAM budget regardless of mode.
PHP-FPM logs a specific warning when all workers are busy:
TEXT
WARNING: [pool www] server reached pm.max_children setting (38), consider raising this value
That message is informational, not a command. "Consider raising" does not mean "blindly raise." If your server is already using most of its RAM, raising max_children makes things worse. The correct response is to figure out why all workers are busy:
  • Slow database queries holding workers longer than necessary
  • External API calls blocking workers for seconds
  • Missing OPcache causing PHP to recompile scripts on every request
  • A stuck or runaway PHP process occupying a worker indefinitely
Fixing those root causes frees up workers without adding more. A worker that finishes in 200 ms instead of 2 seconds handles 10x more requests per minute. That is a far bigger performance gain than doubling worker count. For deeper diagnosis of stuck processes, see Thinking High CPU Means You Need a Bigger Server? Check if a Stuck PHP Process Is the Real Cause. And if you are seeing the max_children warning alongside 502 errors specifically, Reading PHP-FPM Logs to Confirm max_children Is Causing Your 502 Errors walks through the log analysis step by step.
Sometimes the math just does not work. Your site legitimately needs 50 concurrent PHP workers, each using 60 MB, and your 2 GB VPS cannot hold them. At that point, the answer is not a config tweak — it is more RAM. Upgrading the VPS or moving to a larger instance gives you actual capacity to raise max_children safely. Another option: reduce per-worker memory. Enable and properly size OPcache so compiled scripts are stored in shared memory instead of being loaded per-worker. Audit plugins and extensions that bloat memory. Switch from mod_php to PHP-FPM if you have not already (though if you are reading this, you probably have).
pm.max_children is not a performance knob you turn up for speed. It is a capacity limit that must stay within your server's RAM budget. Measure actual worker memory under real traffic, subtract what the OS and other services need, divide, and set the value accordingly. If all workers are busy, investigate why requests are slow before adding more workers. More workers on insufficient RAM does not produce a faster site — it produces 503s and OOM kills.

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.