PHP-FPM Pool Tuning: Why Your Server Stalls at 40 Concurrent Users
pm.max_children is not a performance dial, it is a memory contract. How we size FPM pools from real RSS numbers instead of copying a blog post.

Every few months a client sends the same ticket: "the site is fine all day, then dies for ten minutes around lunch." The CPU graph is flat. Disk I/O is boring. MySQL shows no slow queries. And in the nginx error log, the same line repeats a few thousand times:
[error] 1234#1234: *56789 connect() to unix:/run/php/php8.3-fpm.sock failed
(11: Resource temporarily unavailable) while connecting to upstreamThat is not a hosting failure. That is PHP-FPM refusing new work because the pool is full, and it is nearly always a configuration copied from a tutorial written for a machine that does not resemble yours.
What the pool actually is
PHP-FPM is a process manager. It keeps a pool of worker processes; nginx hands each request to a free worker over a socket. If every worker is busy, requests queue in the listen backlog. When the backlog fills, nginx gets EAGAIN and returns 502.
Four directives govern the whole thing:
| Directive | Meaning | Common mistake | | :--- | :--- | :--- | | pm | Process strategy: static, dynamic, ondemand | dynamic everywhere out of habit | | pm.max_children | Hard ceiling on concurrent PHP requests | Set to 50 on a 2 GB box | | pm.max_requests | Requests before a worker respawns | Left at 0, so leaks never clear | | listen.backlog | Queue depth before refusal | Left at the distro default of 511 |
pm.max_children is the only one that will take a server down, and it is the one people guess at.
Measure RSS before you touch anything
The ceiling is arithmetic, not taste: available memory divided by the real memory footprint of one worker under your workload. Measure it while the site is under normal traffic, not on an idle box.
ps --no-headers -o rss,cmd -C php-fpm8.3 \
| awk class="text-code-string">'{ sum += $1; n++ } END { printf "workers=%d avg=%.0f MB max_seen=%s\n", n, sum/n/1024, "see below" }'
class="text-code-comment">
# Peak, not average — sizing on the average is how you get OOM kills
ps --no-headers -o rss -C php-fpm8.3 | sort -n | tail -1 | awk class="text-code-string">'{printf "peak=%.0f MB\n", $1/1024}'A stock WordPress install with a page builder and WooCommerce lands between 90 MB and 160 MB peak per worker. A lean Laravel API sits closer to 45 MB. Anyone quoting "30 MB per worker" is quoting PHP 5.
Now do the division on a 4 GB VPS also running MySQL and Redis:
total RAM 4096 MB
- OS + sshd + cron 250 MB
- MySQL (innodb_buffer) 1024 MB
- Redis maxmemory 256 MB
- nginx 64 MB
- headroom for page cache 512 MB
---------
available for PHP 1990 MB
peak worker RSS 140 MB
pm.max_children = 1990 / 140 = 14Fourteen. Not fifty. A pool of fifty on that box does not serve fifty users — it invites the OOM killer to reap MySQL, which is a far worse outage than a queued request.
Pick the right process manager
dynamic is the default and the worst fit for a single busy site. It spends its life spawning and reaping workers, and each spawn re-warms opcache for that process.
static— one site owning the box. Every worker is resident, no spawn latency, memory usage is flat and predictable. This is what we run in production.ondemand— many low-traffic sites per server. Workers idle out and return memory; you accept a cold-start penalty on the first hit.dynamic— genuinely spiky traffic on a machine with memory to spare.
A static pool sized from the number above:
; /etc/php/8.3/fpm/pool.d/app.conf
[app]
user = app
group = app
listen = /run/php/app-8.3.sock
listen.owner = www-data
listen.group = www-data
listen.backlog = 1024
pm = static
pm.max_children = 14
pm.max_requests = 500
; Kill runaway requests before they eat the pool
request_terminate_timeout = 60s
slowlog = /var/log/php/app-slow.log
request_slowlog_timeout = 5s
; Expose the status endpoint to localhost only
pm.status_path = /fpm-statuspm.max_requests = 500 is cheap insurance. Most PHP applications leak a little; recycling workers turns a slow leak into a non-event.
Read the status page, not your intuition
Restrict it in nginx to localhost, then watch the two numbers that matter.
location ~ ^/(fpm-status|fpm-ping)$ {
allow 127.0.0.1;
deny all;
include fastcgi_params;
fastcgi_pass unix:/run/php/app-8.3.sock;
}watch -n2 class="text-code-string">'curl -s localhost/fpm-status | grep -E "listen queue|active processes|max children"'- listen queue above zero for more than a second: requests are waiting. Either the pool is too small or something downstream is slow.
- max children reached greater than zero: you have hit the ceiling at least once since boot. If it climbs during normal traffic, the ceiling is wrong.
When the fix is not a bigger pool
This is the part the tutorials skip. If your average request takes 800 ms because every page makes a blocking call to a third-party API, raising max_children just means more workers blocked on the same socket. Little's Law is not negotiable:
required workers = requests per second x average seconds per request
20 req/s x 0.15 s = 3 workers
20 req/s x 0.80 s = 16 workersCutting request time from 800 ms to 150 ms does more for concurrency than any pool change, and it costs no memory. Before resizing, check the slowlog you enabled above — it prints the exact PHP stack that was running when the request crossed five seconds. Nine times out of ten it is an uncached external HTTP call or an unindexed query.
The tradeoffs, stated plainly
| Choice | You gain | You pay | | :--- | :--- | :--- | | static pool | Predictable memory, no spawn latency | Idle workers hold RAM permanently | | High max_children | Absorbs burst traffic | OOM risk; the kernel picks the victim, not you | | Low max_children | Graceful degradation under load | 502s during genuine spikes | | request_terminate_timeout | One bad request cannot hold a worker forever | Long legitimate jobs get killed — move them to a queue |
Set a conservative ceiling, put long work in a worker queue instead of a web request, and let the listen backlog absorb short bursts. A server that queues for 200 ms is healthy. A server that OOM-kills MySQL at noon is not.
Paj Digital Labs
The engineering journal of Paj Digital Solutions — hosting, server infrastructure and web engineering, written by the people who run the servers.
Related reading

PostgreSQL Connection Budgets: Pooling Without Hiding the Bottleneck
More application workers can exhaust database connections long before CPU is full. Budget the whole fleet, understand pool modes and test session behaviour before adding a pooler.

Restore Drills for a Whole Website: Rebuild the Service, Not Just the Database
A database restore can succeed while the website remains unusable. Test files, configuration, identity, DNS and external dependencies in an isolated recovery environment.

TLS Certificate Renewal: Verify the Served Certificate, Not Just the Cron Job
A successful renewal command does not prove visitors see the new certificate. Trace issuance, reloads, proxy termination and external monitoring before an expiry becomes an outage.