I know that there are a lot of related subjects, but I did 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) running along side an apache server.
My problem is that each php-fpm process is consuming too much memory... I mesured it with
ps -ylC php-fpm --sort:rss
And the output was 269 process, each of them with 121Mo in the RSS column, and a total RAM usage on the dedicated server of 3Go.
I also made some php profiling with "memory_get_peak_usage()" php function, and each of my script use an average of 6Mo (peak usage !) and a maximum peak usage of 50Mo (but it is a very specific case). After this profiling, I tried to set the "memory_limit" to 10Mo, the specific case was not working, so I set it to 50Mo and all was ok (normal behaviour).
My two questions are:
As my php scripts does not exceed a peak usage of 50Mo, and as I set a memory_limit of 50Mo, why EACH of my php-fpm process are 121Mo big ?
How is it possible to have 269 processes running with each of them 121Mo big ? The total amout of memory would be 269*121 = 32Go (and when I made this profiling, the total amount of RAM used is the dedicated server was only 3Go ...)
Thanks a lot for your help !