OS Version Information:
[root@localhost system]# cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)
Configuration for the test.slice is as follows:
[root@localhost system]# cat test.slice
[Unit]
Description=Test Slice
Documentation=man:systemd.special(7)
DefaultDependencies=no
Before=slices.target
Wants=-.slice
After=-.slice
[Slice]
CPUAccounting=on
CPUShares=1024
I created another file just like this (call it testhigh.slice) and gave it CPU shares = 128. When I launch CPU hungry processes in either slice, I see CPU get proportionally divided, as expected.
However, there seems to be no way to actually throttle the CPU of one slice to a constant e.g. 10%. The CPUQuota option is not recognized by systemd:
Apr 23 21:34:00 localhost.localdomain systemd[1]: [/usr/lib/systemd/system/test.slice:22] Unknown lvalue 'CPUQuota' in section 'Slice'
In principle, being able to allocate resources precisely would be amazing, but right now I cannot get this to work. Please help; I want a solution from inside the systemd framework, if possible.
Best Answer
The CPUQuota option has only been available since RHEL/CentOS 7.2 (https://www.certdepot.net/rhel-7-2-cpuquota-option/ - please note that I am the author of this site).