You open /var/log/php8.3-fpm.log because visitors are getting 502s, and there it is, scrolled across three hundred lines:
[01-Dec-2026 09:14:22] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it
That little suggestion at the end—consider raising it—has caused more accidental production outages than almost any single log message in the Linux web stack. Debian and Ubuntu still ship www.conf with pm.max_children = 5, which any moderately busy WordPress, Drupal, or Concrete CMS site will blow past before breakfast. So the instinct is totally understandable: open the file, change 5 to 80, reload PHP-FPM, and move on with your day.
Half an hour later SSH freezes. Your monitoring checks time out. When you finally get into the host console and run dmesg -T, you find that the Linux out-of-memory killer just shot MariaDB because eighty PHP workers quietly grew to 110 MB each on an 8 GB machine.
Bumping pm.max_children without checking memory and slow queries doesn’t fix a bottleneck. It just trades slow queued requests for a dead database. Here is how I actually diagnose and size a PHP-FPM pool on a live production box.
What that warning is really telling you
PHP-FPM talks to Nginx or Apache over the FastCGI protocol using a fixed pool of worker processes. One worker handles one HTTP request from start to finish. If a request sits there waiting four seconds for a bad SQL join or a slow payment gateway webhook, that worker is completely unavailable to everybody else until it finishes.
Once all workers up to pm.max_children are busy at the same instant, PHP-FPM logs the warning and stops accepting new work immediately. Incoming connections don’t disappear right away—they queue up inside the Unix socket listen backlog (bounded by listen.backlog and the kernel’s net.core.somaxconn). If the burst clears in a second or two, users just feel a hiccup in TTFB and nobody files a ticket. If the pileup lasts longer than Nginx’s fastcgi_read_timeout (60 seconds by default), Nginx bails out with a 504 Gateway Timeout while PHP keeps chewing on the orphaned request. If the kernel listen queue itself fills up, Nginx throws an instant 502 Bad Gateway.
Notice why this matters before you edit anything. You hit pm.max_children for one of two very different reasons. Either you genuinely have more concurrent dynamic traffic than five workers can serve, or your PHP execution time quietly crept up from 150 ms to 3 seconds and every worker is now parked in traffic. Throwing fifty more workers at a slow database query only multiplies lock contention until the whole machine tips over.
Measure actual worker RAM first (and stop trusting raw RSS)
Most tuning guides tell you to run ps -ylC php-fpm --sort:rss, average the RSS column, and divide your free RAM by that number. On modern Linux systems running PHP 8.2, 8.3, or 8.4 with OPcache turned on, raw RSS lies to you in both directions.
RSS (Resident Set Size) counts shared memory pages inside every single child process. If PHP-FPM keeps a 256 MB shared OPcache segment mapped across twenty workers, RSS charges that shared memory to all twenty PIDs over and over. You end up thinking a 55 MB worker eats 140 MB and artificially starve your pool. Worse, if you ignore measurement altogether and use the classic forum advice of “assume 30 MB per PHP process,” a bloated WooCommerce or multilingual CMS install will eat 150 MB of private heap per child and blow straight through your RAM ceiling.
What you actually want is PSS (Proportional Set Size). The kernel calculates PSS by dividing shared pages evenly across the processes sharing them and adding each worker’s private dirty heap on top. Install smem if you have package access (sudo apt install smem) and run it during normal daytime traffic—not right after a reload when workers haven’t warmed up yet:
sudo smem -t -k -c "pid user command pss rss" -P "php-fpm"
If you’re on a locked-down server where you can’t install packages, read smaps_rollup directly from /proc instead:
for pid in $(pgrep -f "php-fpm: pool www"); do
awk '/^Pss:/ {sum += $2} END {printf "PID %s: %.1f MB PSS\n", "'"$pid"'", sum/1024}' /proc/$pid/smaps_rollup 2>/dev/null
done
Take the average PSS across ten or fifteen mature workers (ignore the single master process). On real sites I’ve audited recently, a lean Laravel or custom PHP service usually settles around 30 to 45 MB PSS. A clean WordPress install with Redis object caching runs 55 to 85 MB. Heavy WooCommerce shops, Elementor-heavy marketing sites, or enterprise Drupal 10/11 and Concrete CMS builds regularly sit between 100 and 170 MB per worker once they’ve handled a few dozen requests.
One detail people always overlook during replatforms: worker memory changes after major framework upgrades. Whenever we guide a team through a Concrete5 to Concrete CMS migration or work through a Drupal relaunch checklist, we re-measure PSS in staging under load before flipping DNS. New Composer dependencies and PHP 8.3/8.4 OPcache buffers routinely shift worker weight by 20% to 35%.
Work backward from your real memory ceiling
Before picking a worker count, account for everything else living on the same server. On a single VPS running Nginx, MariaDB or MySQL, Redis, and PHP-FPM together, the database buffer pool is almost always your largest tenant. Never look at free -h right after a reboot and assume all “available” RAM belongs to PHP—MariaDB hasn’t filled its innodb_buffer_pool_size yet.
Walk through an ordinary 8 GB Linux VPS (about 7,800 MB usable by the kernel). Give the OS, systemd, journald, and Nginx roughly 1,200 MB. If MariaDB has a 2 GB InnoDB buffer pool, budget 2,600 MB once you include per-connection sort buffers and temporary tables. Give Redis 650 MB if maxmemory is set to 512 MB (memory fragmentation adds overhead). Hold back another 15%—roughly 1,170 MB—so a nightly backup, log rotation, or brief spike never wakes up the OOM killer.
That leaves 7,800 - 5,620 = 2,180 MB genuinely free for PHP-FPM. At 85 MB PSS per worker, 2,180 / 85 gives you 25 workers. Not 50, not 100.
Below are the safe starting ranges I use on all-in-one VPS nodes hosting Nginx, MariaDB, Redis, and PHP-FPM on the same machine:
| Server RAM | Usable PHP-FPM Budget | Lean PHP (45 MB) | Typical CMS (85 MB) | Heavy Store (140 MB) |
|---|---|---|---|---|
| 2 GB | ~600 MB | 12 | 7 | 4 |
| 4 GB | ~1,200 MB | 26 | 14 | 8 |
| 8 GB | ~2,200 MB | 48 | 25 | 15 |
| 16 GB | ~5,200 MB | 110 (watch CPU) | 60 | 37 |
| 32 GB (app only) | ~22,000 MB | CPU-bound | 240 (watch DB) | 150 |
Pay attention to the notes on the bigger boxes. Once you cross 16 GB of RAM, memory stops being your only wall. Putting 110 active PHP workers on a 4-vCPU server just creates violent context-switching where every page takes four times longer. In practice, keep active workers below 8x to 12x your CPU core count unless your app spends most of its time blocked on external network calls. Also check MySQL’s max_connections—if PHP-FPM can open 150 concurrent database connections and MariaDB defaults to 151, you will immediately trade pm.max_children warnings for MySQL Error 1040 outages.
If you’d rather not do this math by hand every time you spin up a new node, you can plug your server RAM, worker PSS, and average PHP response time into our PHP worker calculator and get a clean www.conf baseline in seconds.
Use Little’s Law to see whether you have a traffic problem or a code problem
Memory tells you how many workers your box can afford. Little’s Law (L = λ × W) tells you how many workers your traffic actually needs. Here, λ is your arrival rate of uncached dynamic PHP requests per second (static CSS, JS, images, and cached HTML never touch PHP-FPM), and W is your average PHP execution time in seconds.
Look at how dramatically execution speed changes your worker count on a site handling 20 uncached requests per second. When PHP finishes in 200 milliseconds (0.20s), you need 20 × 0.20 = 4 concurrent workers. An 8-worker pool coasts through that effortlessly. Now suppose a bad plugin update or a missing database index stretches average PHP execution to 2.5 seconds. Suddenly the exact same traffic requires 20 × 2.5 = 50 concurrent workers. Zero new visitors arrived, yet your 25-worker server just drowned in 504 timeouts.
That’s why I never tell clients to upgrade their VPS on the first pm.max_children alert. Cut response time from 1.8 seconds down to 250 milliseconds and you just freed up 85% of your PHP worker pool for free. You can model that trade-off directly inside the CMS Connection PHP Worker Calculator before signing off on a bigger hosting bill.
Turn on the PHP-FPM slowlog before raising anything
Whenever somebody tells me they bumped pm.max_children from 20 to 60 and it still maxes out every morning at ten o’clock, I don’t touch the worker limit again until I read a slowlog. Open your pool config (usually /etc/php/8.3/fpm/pool.d/www.conf on Ubuntu/Debian or /etc/php-fpm.d/www.conf on Rocky/AlmaLinux) and add:
slowlog = /var/log/php8.3-fpm-slow.log
request_slowlog_timeout = 3s
request_terminate_timeout = 60s
Reload PHP-FPM and let it capture traffic for fifteen minutes during a busy window. When you open /var/log/php8.3-fpm-slow.log, PHP hands you the exact call stack of whatever is holding workers hostage:
[01-Dec-2026 10:08:19] [pool www] pid 19482
script_filename = /var/www/html/index.php
[0x00007f8a12413910] curl_exec() /var/www/html/wp-includes/Requests/src/Transport/Curl.php:204
[0x00007f8a124137a0] request() /var/www/html/wp-includes/Requests/src/Requests.php:469
[0x00007f8a12413620] fetch_inventory_sync() /var/www/html/wp-content/plugins/erp-connector/sync.php:88
I see variations of that stack trace every single week. An ERP sync plugin, CRM webhook, or license-check call fires a synchronous curl_exec() during a live page render. When the third-party API stalls for ten seconds, every PHP worker freezes in line waiting on cURL until the entire pool locks up. No value of pm.max_children fixes a blocking remote HTTP call on the critical path; caching the response in Redis or pushing the sync into a background worker fixes it permanently.
The other culprit that fills pools even on low-traffic sites is bot spam hitting uncached URLs. Check your Nginx access logs when the warning fires. Nine times out of ten, an aggressive AI scraper or broken crawler is hammering faceted search query strings like /?s=boots&color=black&sort=asc or brute-forcing /xmlrpc.php. Because query strings bypass page caches, a single bot firing fifteen requests per second can pin a small PHP-FPM pool flat on its back. Rate-limiting search endpoints in Nginx and disabling pseudo-cron (define('DISABLE_WP_CRON', true); replaced by a real 5-minute Linux cron job) clears half the pm.max_children tickets I ever touch.
Choosing between dynamic, static, and ondemand pools
Once your slowlog is clean and you know your real RAM ceiling, update your pool settings in www.conf. Most people leave pm = dynamic alone, which is completely fine for a shared VPS or a site with predictable daytime peaks and quiet nights. For the 8 GB server we calculated at 25 max workers earlier, a sensible dynamic pool looks like this:
[www]
user = www-data
group = www-data
listen = /run/php/php8.3-fpm.sock
listen.backlog = 1024
pm = dynamic
pm.max_children = 25
pm.start_servers = 8
pm.min_spare_servers = 6
pm.max_spare_servers = 14
pm.max_requests = 500
pm.status_path = /fpm-status
Don’t skip pm.max_requests = 500. PHP extensions and large CMS frameworks inevitably accumulate small memory leaks over thousands of requests. Recycling each child gracefully after 500 requests keeps PSS flat across weeks of uptime without any visible dip in latency. Also bump listen.backlog to 1024 and make sure net.core.somaxconn = 4096 is set in /etc/sysctl.conf, otherwise the kernel silently caps PHP-FPM’s backlog back down.
When does pm = static beat dynamic? On a dedicated production node running one high-traffic store or publishing portal where the RAM is already paid for and sitting there anyway. Under a sudden flash sale or newsletter spike, pm = dynamic has to fork fresh PHP processes right at the exact second your CPU hits 95%. Switching to pm = static with pm.max_children = 40 and pm.max_requests = 500 keeps every worker warm in memory with zero fork overhead.
Reserve pm = ondemand for staging boxes or multi-tenant servers hosting twenty small brochure sites that barely get a hit every few minutes. On a busy site, ondemand adds fork latency to cold requests and makes burst traffic feel choppy. If you manage multiple high-value properties on shared infrastructure, separating each site into its own isolated PHP-FPM pool with a dedicated Linux user and explicit pm.max_children cap stops one noisy tenant from starving the rest—a core operational standard we cover in our breakdown of enterprise CMS architecture benefits and our comparison of Magnolia, Kentico, and Acquia.
Verify your tuning with /fpm-status instead of guessing
Before you reload PHP-FPM, always validate the configuration syntax so a stray typo doesn’t kill the service:
sudo php-fpm8.3 -t && sudo systemctl reload php8.3-fpm
Use reload rather than restart. Reloading sends USR2 to the master process so in-flight checkout requests and editorial saves finish cleanly before old workers exit.
Finally, wire up pm.status_path = /fpm-status inside Nginx restricted strictly to localhost (never expose it to the public internet):
location = /fpm-status {
allow 127.0.0.1;
deny all;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
Poll it over SSH during peak hours with curl http://127.0.0.1/fpm-status. You want output that looks roughly like this:
pool: www
process manager: dynamic
active processes: 9
max active processes: 19
listen queue: 0
max listen queue: 0
max children reached: 0
Watch those bottom three lines across a full 24-hour cycle. If max children reached stays at zero, max listen queue stays at zero, and free -h still shows at least 20% headroom, you’re done. If max listen queue still climbs even after you’ve reached your server’s safe memory ceiling, stop pushing pm.max_children higher—your next real gains come from Nginx FastCGI microcaching for anonymous visitors, Redis object caching, or moving the database onto its own node.
Common edge cases that trip people up
Why am I hitting pm.max_children when Google Analytics shows almost no visitors?
Analytics only runs JavaScript in human browsers. Bots, vulnerability scanners, XML-RPC brute-forcers, and AI crawlers never trigger GA4, yet every uncached request they send still occupies a full PHP worker. Always cross-check raw Nginx access logs before assuming your pool size is wrong.
Can I safely set pm.max_children = 50 on a 4 GB VPS?
Only if you enjoy waking up to crashed MySQL tables. Fifty WordPress or Drupal workers averaging 85 MB PSS want more than 4 GB of RAM on their own, leaving nothing for the kernel or database. Keep a 4 GB all-in-one server around 12 to 16 workers and let Nginx page caching handle anonymous traffic spikes.
Will raising pm.max_children speed up a slow 3-second page load?
Only if the page was sitting in the socket listen queue waiting for a free worker. Once listen queue is zero, adding more workers won’t shave a single millisecond off response time. Speeding up individual requests means fixing slow SQL queries, enabling OPcache and Redis, or removing blocking cURL calls caught in your slowlog.
What value should I use for pm.max_requests?
Anywhere between 500 and 1000 works well for almost every production CMS stack. Lower than 100 wastes CPU respawning workers too often; leaving it at 0 (unlimited) lets tiny memory leaks grow indefinitely until a random weekday OOM crash.