I am interested in trying to override the CPU utilisation of a systemd service. So that I don't lockup the machine on some CPU heavey process that I run periodically.
After running systemctl edit containerd.service
I see that there are two [Service] sections.
For example:
systemctl cat containerd.service
# /lib/systemd/system/containerd.service
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target
[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/bin/containerd
Delegate=yes
KillMode=process
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=infinity
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
[Install]
WantedBy=multi-user.target
# /etc/systemd/system/containerd.service.d/override.conf
# https://unix.stackexchange.com/questions/494843/how-to-limit-a-systemd-service-to-play-nice-with-the-cpu
# https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html
[Service]
CPUAccounting=True
CPUQuota=95%
MemoryAccounting=True
MemorySwapMax=0
When I look at the specific values
systemctl daemon-reload
systemctl show containerd.service | grep MemorySwap
MemorySwapMax=infinity
They don't show up as having changed. Am I misunderstanding how all this is supposed to work.
When I look at a different value it does show up as changed. Previously CPUAccounting= was empty
systemctl show containerd.service | grep CPUAccountin
CPUAccounting=yes
Further info
systemctl --version
systemd 237
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid
uname -a
Linux srv-acquisitions02 4.15.0-66-generic #75-Ubuntu SMP Tue Oct 1 05:24:09 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux