CPU, RAM and IO Limits whith Cgroups and Systemd

Banko StoyanovOctober 11, 20201min0
cpu-test-with-limit-on11.jpg

Systemd made imposing a limits on a customer account so they do not bring the server down relatively easy.

You just need to ensure that it cgroups are fully enabled .

 

nano /etc/default/grub

 

find GRUB_CMDLINE_LINUX=”  ” and add the systemd.unified_cgroup_hierarchy=1 there, save

 

update-grub && reboot

 

Next execute

systemctl set-property user.slice CPUAccounting=1

systemctl set-property user.slice MemoryAccounting=1

systemctl set-property user.slice IOAccounting=1

systemctl daemon-reload

systemctl restart user.slice

 

Create slices for every user on the server with their limits

/etc/systemd/system/user-1000.slice

where 1000 is the UID and set there your limits

 

[Slice]

CPUQuota=100%

MemoryMax=2G

IOReadBandwidthMax= / 15M

IOWriteBandwidthMax= / 15M

IOReadIOPSMax= / 1024

IOWriteIOPSMax= / 1024

 

CPUQuota 100% is equal to 1 CPU core (HT)

Memory Limit and Block IO can be K,M,G …

/ is device or just paht /var/log for example

Some varibles differs from the DA forum post as i finally managed to find updated docs

 

Banko Stoyanov

This blogpost is written by Banko Stoyanov. Stoyanov is a Marketing manager at CooliceHost. Stoyanov holds an MBA in Marketing strategy and Business developing. He's passionate about data analysis, consumer behavior, cloud technology, and marketing. He is a lifelong learner who regularly keeps himself updated with the latest technologies and industry advancements. In his free time, he explores coffee scene and stays active through running and fitness. Find him on Linkedin and Facebook.


Leave a Reply

Your email address will not be published. Required fields are marked *


Copyright © 2024 – CooliceHost.com – All Rights Reserved.