Recently, I've run into some issues with my system. I have scheduled tasks that are supposed to make my life easier by automatically doing maintainence for me. The problem is that, if I happen to be using my PC while these tasks run, it slows down everything and interferes with my productivity. I could disable the tasks when I'm using the computer, but that doesn't seem like a good enough solution, since I want to have them run no matter what, I just want them to not bother me. It turns out that SystemD has some fairly advanced resource management capabilities. Most people don't have a reason to use these settings because they will be preconfigured by the distro or system admin, but for someone like me that has a very customized local configuration, they can come in handy.

SystemD can use Linux CGroups to set restrictions on service resource access. In my case, I'm interested in CPU and disk access, although CGroups are much more flexible than what I need.

I found the services which were slowing down my computer and ran the following commands:

systemctl  set-property <service> CPUQuota=50%
systemctl  set-property <service> CPUWeight=1
systemctl  set-property <service> IOWeight=1

This changes, only for the current boot (the settings are lost on system shutdown), the resource access for . CPUQuota sets the allowed percentage of one core/processor, so on my pc, 50% gives half of one out of my eight cores. CPUWeight is an integer between 1 and 10000 that is used to scale the amount of time the process gets on the processor, 1 is the lowest, 10000 is the highest. IOWeight is similar to CPUWeight but for the amount of data that gets written or read, this one was particularly important for me, because the service was writing huge chunks to my hard drive and blocking the whole system.