Speed and caching1 min readUpdated

PHP workers and memory: sizing for traffic

How many PHP requests can run at once, how that relates to memory, and how to tune pm.max_children.

Every PHP request runs in a worker. The number of workers (pm.max_children) is how many uncached requests an application can answer at the same time.

A simple rule

Workers × memory per request must fit in the memory left after MariaDB, Redis, OpenSearch and the system. A Magento request typically uses 100 to 300 MB; a WordPress request 50 to 150 MB.

Server memoryTypical Magento workersTypical WordPress workers
8 GB8 to 1215 to 25
16 GB16 to 2430 to 40
32 GB30 to 4550 to 70

More workers than the memory can hold makes the server swap. Everything slows down at once. If the Memory graph is always full, lower the workers or add Varnish rather than raising them.

Symptoms of too few workers

  • 502 or 504 errors during peaks while CPU is not full.
  • server reached pm.max_children in the PHP error log.

Varnish and the browser check reduce the number of requests that need a worker at all. They are often a better answer than more workers.

Did this solve it? If not, tell us what you see and we look at your server.

Open a ticket

Still stuck? Ask a person.

Tickets go straight to the engineers who run ShopWhizzy servers. Tell us the store, what you see and when it started, and we take it from there.