How to Tune PHP-FPM for Your WordPress Server

How to Tune PHP-FPM for Your WordPress Server

PHP-FPM is the process manager that runs PHP for your site. Its settings decide how many requests can run at the same time. Set them too low and traffic queues up; set them too high and the server runs out of memory and crashes. Here is how to size them correctly.

The setting that matters most

pm.max_children is the maximum number of PHP worker processes. The right number is roughly:

(RAM available for PHP) divided by (average memory per PHP process)

If you have 2 GB free for PHP and each process uses about 80 MB, that is around 25 workers. Going higher just invites the out-of-memory killer.

Calculate it correctly

  1. Open the PHP-FPM Calculator.
  2. Enter your total RAM, what you reserve for the OS and database, and your average process size.
  3. It gives you pm.max_children plus sensible start_servers, min_spare_servers, and max_spare_servers.

Find your real process size

Do not guess the per-process memory. On the server, check actual PHP-FPM processes (for example with ps or your hosting dashboard) and use the real average. WordPress with a page builder and heavy plugins can use 60 to 120 MB per process; a lean site much less.

pm: dynamic vs ondemand

  • dynamic keeps a pool of workers ready. Good for steady traffic.
  • ondemand spawns workers only when needed and kills idle ones. Good for low-traffic or memory-tight servers.

Most WordPress sites do well on dynamic with the values from the calculator.

Measure your real process size, divide your available RAM by it, and set pm.max_children to that. Stable under load, no wasted memory.

← All posts