I know that there are many related topics, but I have not found my answer.
I have a dedicated server with 32Go of RAM (but I want PHP-fpm to use only 12Go max), and I have a PHP Fpm (7.2.13) that runs alongside an Apache server.
My problem is that every PHP FPM process consumes too much memory …
I measured it
ps -ylC php-fpm --sort: rss
The output included 269 processes, each with 121 MB in the RSS column, and a total of RAM on the dedicated 3Go server.
I've also created some PHP profiles with the PHP function "memory_get_peak_usage ()" and each of my scripts uses an average of 4Mo (peak load!) And a maximum peak load of 50Mo (this is a very special case though).
After profiling, I tried to set "memory_limit" to 10Mo, the special case did not work, so I set it to 50Mo and everything was fine (normal behavior).
My two questions are:
Since my PHP scripts do not exceed a peak usage of 50Mo and I set a memory limit of 50Mo, why is ANY of my PHP FPM processes 121M?
How is it possible to run 269 processes with 121 million each? The total amount of memory would be 269 * 121 = 32Go (and when I did this profiling, only 3Go RAM was used for the dedicated server altogether …)
Thank you for your help !