I've been trying to limit the CPU usage of PHP-FPM processes for a specific user on my RHEL 8 server using cgroups, but I'm facing an issue where the cgroups are not working as expected. Previously, I used cgred to achieve this, but it has been deprecated in RHEL 8, so I had to switch to using cgroups directly.
Created a new cgroup for the user using the command
sudo cgcreate -g cpu:/my_cgroup
.Set the CPU quota for the cgroup using the command
sudo cgset -r cpu.cfs_quota_us=100000 /my_cgroup
, which should limit the CPU usage to 10% for the user.
I can see the new cgroup is created successfully using the sudo cgget -g cpu:/my_cgroup
command, but whenever a PHP-FPM process is started by the user, the CPU usage is not being limited as expected. Here's what I've tried so far:
Edited the PHP-FPM configuration file
/etc/php-fpm.d/www.conf
and added a slice specifically for the user, but it didn't take effect.Added the cgroup directive directly in the PHP-FPM configuration file using
php_admin_value[cgroup] = /sys/fs/cgroup/cpu/USER
, but it also didn't work.
I've also checked the running PHP-FPM processes using ps -e -o pid,user,cgroup,args | grep php-fpm
and verified that the cgroup path matches the expected path for the user.
What could be causing this issue? How can I limit the CPU usage of PHP-FPM processes for a specific user using cgroups on RHEL 8?