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.
The systemd shipping with RHEL/Centos 7 is based on version 208. That CPUQuota support doesn't appear to be included until 213.
You should be able experiment by running the process in the slice/scope you want and then directly modifying the cpu.cfs_{quota,period}_us ratio under /sys/fs/cgroup/cpu/... I expect whatever you set there for stick for a while so long as there isn't any systemd activity that would cause it to re-write into the files.