I am trying to optimize the parameters of PHP-FPM on a VPS with multiple domains. Each domain is configured with its own user/group, NGINX uses different PHP-FPM sockets. For each domain I have configured the right user/group.
I found out that the memory usage was too high, the cause was a bad configuration of the children/server parameters on PHP-FPM.
The configuration for each site is as follows (relevant part only):
pm = dynamic pm.max_children = 6 pm.start_servers = 2 pm.min_spare_servers = 2 pm.max_spare_servers = 4 pm.max_requests = 300
There are 11 domains configured, with 6 GB of total RAM assigned. Max memory usage should be less than 64 MB for each PHP-FPM instance (htop shows a max of 50 MB usage), at max usage I should reach ~4 GB of RAM.
I think I am limiting max_children way too much, how can I find out the best value? I guess checking the real hits/days on each site will help finding those values? Am I missing some php-fpm "global" parameter?
; The maximum number of processes FPM will fork. This has been design to control ; the global number of processes when using dynamic PM within a lot of pools. ; Use it with caution. ; Note: A value of 0 indicates no limit ; Default Value: 0 ; process.max = 128
in /etc/php-fpm.conf? Considering the number of domains on the server i could increase the max_children and add a limit to the global process spawned, right?