PHP-FPM tuning: Using 'pm static' for max performance

Originally published at: PHP-FPM tuning: Using 'pm static' for max performance

Let’s take a very quick look at how best to set up PHP-FPM for high throughput, low latency, and more stable CPU and memory use. By default, most setups have PHP-FPM’s PM (process manager) string set to dynamic and there’s also the common advice to use ondemand if you suffer from available memory issues. However, let’s…

Hi @hydn

Thanks for the article, really helpful.

Have you considered the impact of these settings in a modern containerised environment?

I’m running a single PHP container for a low traffic website. Over time this traffic will grow, and at some point, will be fairly substantial.

I’m using the default settings - dynamic, 5 children, etc. - on a container with 0.5 vCPU and 1GB RAM.

I would like to be able to horizontally scale these containers so that when traffic increases I can bring new containers online. Ideally, I would do this automatically, based on the amount of CPU or memory the current container(s) are using (e.g. once they hit a threshold of 80%, a new container comes online).

What settings would you recommend for this environment?

1 Like


When scaling using the hardware (0.5 vCPU and 1GB RAM) then no this article wouldn’t really apply. You can provide feedback and recommendations you find to work well for other readers.

Thanks for the feedback.

Hi @dunc
The pm.static setting is important for this environment and probably the only one possible.
For scaling, you then need to use not only CPU and RAM values, but also the number of active PHP processes. Because if pm.max_children is set to 50 and there are 40 active processes and 10 idle, it’s time to start another container regardless of RAM and CPU consumption.
So, for scaling purposes, we need to keep php status active and evaluate the values of active (or idle) PHP processes periodically at short intervals.

The specific setting depends on the technology used, if it’s some containerization system or kubernetes.

1 Like