understand correctly pm.max_children tuning
Your calculation is correct from what I gather.
Having many webs on the same server works only as long as not all webs use all available resources at the same time. This is what people usually call overprovisioning.
However, I suggest not to simply calculate pm.max_children
around the available RAM, but around how many workers are actually necessary for the webs to function properly. Start with something lower and monitor the the php-fpm.log
. If the max_children
setting is reached, you will find it in the log and you can increase it.
Also, make sure that the PHP workers only live as long as necessary. For example, the following configuration will let a pool use up to 32 PHP workers if there is a burst of requests, but each worker will exit after 3 seconds of inactivity and free valuable RAM:
pm = ondemand
pm.max_children = 32
pm.process_idle_timeout = 3s
Use the ondemand
process manager if you are low on RAM. It is a bit slower than the dynamic
pm, but doesn't waste RAM for inactive websites.
If you want to control the total number of PHP processes, there is a setting called process.max
in php-fpm.conf
. I have never used it, but it seems to me you could use it to ensure that there are never more than a certain number of workers, regardless of how the pools are configured.
By the way, it is a very good idea to use separate pools for separate webs belonging to separate users. That way you won't have any problems with user permissions or with data cached from other webs.