I have a CentOS 7.4 system which has a number of users who access the system via SSH. I need a way to prevent them from consuming all CPU and memory of the system. For example, each user getting 1 CPU core or a "1/20th share" of CPU time is fine.
The closest I have is based on setting the CPUQuota property of each user slice after a user logs in. I did this but the settings have no effect. What am I missing?
DefaultCPUAccounting=yesset then rebooted
- Logged in as test user
systemctl set-property user-43045.slice CPUAccounting=yes CPUQuota=20%
- As the user, in a shell within the cgroup (systemd-cgls):
dd if=/dev/zero of=/dev/null bs=1024k
Still no limit to CPU usage. Is there any supported, not deprecated way to limit SSH users? Both the cgconfig+cgred method and the PAM method do not appear to work at all on CentOS 7.
EDIT #1 - and solution
After making the same change to
CPUQuota option now has an effect. So systemd requires tracking things in both system and user for some reason.