Symptoms
- The server is slow and websites take too long to load or they do not load at all, while generating 504 errors at the same time
- The Apache error log indicates that the Apache web server is having difficulties with the termination of some processes:
[Fri Nov 17 16:11:45.225766 2023] [core:warn] [pid 27150:tid 139707243858880] AH00045: child process 29995 still did not exit, sending a SIGTERM
[Fri Nov 17 16:11:45.225929 2023] [core:warn] [pid 27150:tid 139707243858880] AH00045: child process 31367 still did not exit, sending a SIGTERM
[Fri Nov 17 16:11:45.226032 2023] [core:warn] [pid 27150:tid 139707243858880] AH00045: child process 959 still did not exit, sending a SIGTERM
...
[Fri Nov 17 16:11:47.250484 2023] [core:error] [pid 27150:tid 139707243858880] AH00046: child process 29995 still did not exit, sending a SIGKILL
[Fri Nov 17 16:11:47.250957 2023] [core:error] [pid 27150:tid 139707243858880] AH00046: child process 31367 still did not exit, sending a SIGKILL
[Fri Nov 17 16:11:47.251313 2023] [core:error] [pid 27150:tid 139707243858880] AH00046: child process 959 still did not exit, sending a SIGKILL -
The command below shows high RAM usage:
# free -h
-
The command below shows more PHP-FPM child processes than allowed under pm.max_children in Domains > example.com > PHP Settings:
# ps faux | grep fpm
...
root 2482 0.0 0.2 583108 20784 ? Ss Jan16 0:55 php-fpm: master process (/opt/plesk/php/7.4/etc/php-fpm.conf)
exampl+ 17707 4.0 0.2 583800 22940 ? S 15:28 0:00 _ php-fpm: pool example.com
exampl+ 17707 4.0 0.2 583800 22940 ? S 15:28 0:00 _ php-fpm: pool example.com
exampl+ 17707 4.0 0.2 583800 22940 ? S 15:28 0:00 _ php-fpm: pool example.com
exampl+ 17707 4.0 0.2 583800 22940 ? S 15:28 0:00 _ php-fpm: pool example.com
exampl+ 17707 4.0 0.2 583800 22940 ? S 15:28 0:00 _ php-fpm: pool example.com
exampl+ 17707 4.0 0.2 583800 22940 ? S 15:28 0:00 _ php-fpm: pool example.com
exampl+ 17707 4.0 0.2 583800 22940 ? S 15:28 0:00 _ php-fpm: pool example.com
exampl+ 17707 4.0 0.2 583800 22940 ? S 15:28 0:00 _ php-fpm: pool example.com
exampl+ 17707 4.0 0.2 583800 22940 ? S 15:28 0:00 _ php-fpm: pool example.com
exampl+ 17707 4.0 0.2 583800 22940 ? S 15:28 0:00 _ php-fpm: pool example.com
...
exampl+ 17707 4.0 0.2 583800 22940 ? S 15:28 0:00 _ php-fpm: pool example.com
Cause
The pm variable in PHP Settings is set to ondemand, which means that the Apache web server will spawn as many PHP-FPM processes as required by the site, ignoring the pm.max_children variable and that can overwhelm your Apache web server if the website code is not written in a way that would make the processes exit on their own.
Resolution
-
Go to Domains > example.com > PHP Settings
-
In the pm dropdown, choose either static (the domain will always have the same amount of child processes) or dynamic (the number of child processes will grow as required, but will be limited by pm.child_processes).