PM settings explained: this guide shows how PHP-FPM decides how many workers handle requests, and how to tune those settings for high-traffic sites.
When a traffic spike hits, PHP-FPM decides how many PHP workers handle requests, how quickly new workers start, and when idle workers go away. Get those settings wrong and the site either queues requests while workers sit idle, or spawns workers until memory runs out and the server starts swapping. This guide explains PHP-FPM pm settings in plain terms, so you can tune them from measurements instead of copying values from a forum post. In short, this is pm settings explained for a server you actually run.
PHP-FPM is the process manager that runs PHP for Nginx and other web servers. The php-fpm process manager reads its php-fpm pool configuration from a file like /etc/php/8.3/fpm/pool.d/www.conf, and the lines that matter most start with pm. Change them, reload PHP-FPM, and watch the result before you change anything else.
PHP-FPM PM Settings Explained: The Three Process Managers
The pm setting picks one of three strategies: static, dynamic, or ondemand. Each one suits a different kind of traffic.
With pm = static, PHP-FPM starts a fixed number of workers and keeps them running. The count comes from pm.max_children. Static is simple and predictable, which makes it a good fit for a busy site with steady traffic. The cost is memory: every worker holds memory whether it serves requests or not.
With pm = dynamic, PHP-FPM starts pm.start_servers workers, then grows toward pm.max_children under load and shrinks back toward pm.min_spare_servers when traffic drops. Dynamic suits traffic that rises and falls during the day, because idle workers release memory when the site quiets down. The trade-off is a short delay when new workers must start during a sudden spike.
With pm = ondemand, PHP-FPM starts no workers at all and spawns one only when a request arrives. Workers die after pm.process_idle_timeout seconds of idleness. Ondemand saves the most memory, which suits a quiet site or a server running many small pools. It is a poor fit for a busy site, because every burst pays the cost of starting fresh processes. Choosing between php-fpm dynamic vs static comes down to traffic shape: steady traffic favors static, variable traffic favors dynamic.
How to Size pm.max_children
The most important number is pm.max_children, and the wrong way to set it is to pick a round number. In plain terms, the pm max children value is the hard ceiling on simultaneous PHP workers. Size it from memory. Find how much memory one PHP worker uses on your site by checking process sizes while the site runs under normal load, then divide the memory you can spare for PHP by that per-worker figure. Leave room for the operating system, the database, and Nginx. A server with 4 GB of RAM, a database, and workers that each use 50 MB cannot safely run 80 children, because 80 workers would need 4 GB before anything else gets a byte.
When pm.max_children is too low, requests queue and visitors see slow pages or timeouts while CPU and memory sit half empty. When it is too high, the server runs out of memory, starts swapping, and everything slows down at once. Watch the PHP-FPM status page or your logs for the warning that the pool reached its child limit. That message means the ceiling is too low for the traffic, not that the server needs more RAM right away.
Raise the limit in small steps, one change at a time, and measure after each change. If raising it helps up to a point and then hurts, you found the real ceiling: the point where memory pressure, not worker count, limits the site. Pair this tuning with the web server side, since PHP workers only help if Nginx can hand them requests fast enough; our guide to Nginx concurrent connection tuning covers the matching connection limits.
Spare Servers and Request Limits
For dynamic pools, pm.start_servers sets the workers ready at startup. Set it near your normal traffic level, not near your peak. pm.min_spare_servers and pm.max_spare_servers set the floor and ceiling for idle workers. Keep the range modest: too many spare workers waste memory, and too few mean every small traffic rise pays process startup costs.
Two more settings shape behavior under sustained load. pm.max_requests restarts a worker after it serves that many requests, which clears slow memory growth in long-lived workers. A value in the low hundreds to around a thousand suits most sites. Setting it to zero disables restarts, which is fine for a worker pool you watch closely but risky for one you never inspect.
Also check request_terminate_timeout. It kills a PHP request that runs longer than the limit, which stops one stuck script from holding a worker hostage. Set it above your slowest legitimate request, not below it, or normal work like a large import will die mid-run. If you run WordPress, caching changes the math entirely, because cached pages never reach PHP at all; see our guide to Nginx caching for WordPress at scale before you raise worker counts for traffic that a cache could absorb.
A Practical Tuning Sequence
Start by measuring. Note current traffic, average worker memory, and the point where the pool hits its child limit. Then follow this order:
- Pick the process manager: static for steady high traffic, dynamic for variable traffic, ondemand for quiet sites.
- Size
pm.max_childrenfrom measured worker memory and available RAM. - Set spare servers near normal load, not peak load.
- Set
pm.max_requestsso workers recycle before memory growth becomes a problem. - Reload PHP-FPM, watch the status page and error log for a full traffic cycle, then adjust once.
Do not change five settings at once. If performance improves, you will not know which change did it, and if it gets worse, you will not know what to undo. One change, one measurement, one decision. That discipline is the whole difference between tuning and guessing.
Finally, remember that PHP-FPM tuning has a ceiling set by the rest of the stack. A slow database or an uncached page will still be slow with twice the workers. When worker tuning stops helping, the bottleneck moved elsewhere. At that point, compare web server options in our Nginx vs Apache for high-traffic sites comparison, and check what your monitoring actually shows, using the metrics in our Linux server monitoring basics guide, before you buy a bigger server.