cgroups and (my)Vesta
Posted: Thu Jan 20, 2022 10:48 am
To install cgroups, run:
in /etc/cgconfig.conf put:
Then in /etc/cgrules.conf put:
Create (my)Vesta user testaccount1 and testaccount2 .
In this example we will limit CPU to testaccount1, and we will limit storage I/O to testaccount2 .
Then run:
cgrulesengd run only once (it's like a starting a service)
cgconfigparser run on each config change.
Add both cgconfigparser and cgrulesengd to some start up script (for example /etc/rc.local if you have it), in order to start cgroups after server restart.
Code: Select all
apt-get update
apt-get install cgroup-tools
in /etc/cgconfig.conf put:
Code: Select all
group limit0cpu50 {
cpu {
cpu.cfs_quota_us="500000";
cpu.cfs_period_us="1000000";
# all threads collectively are allowed to work for half a second out of a total of one second
cpu.shares=1000;
}
cpuset {
cpuset.cpus="0,1,2,3";
# "0,1,2,3" determines on which CPU threads it is allowed to run
cpuset.mems="0";
# you can omit "cpuset.mems"
}
}
group limitio {
blkio {
blkio.throttle.read_bps_device = "maj:min 10485760";
blkio.throttle.write_bps_device = "maj:min 10485760";
blkio.throttle.read_iops_device = "maj:min 10";
blkio.throttle.write_iops_device = "maj:min 10";
# instead of "maj:min" put two numbers that identified your partition/raid, run "lsblk" to see MAJ:MIN number for desired partition/raid
# this example set a 10 MB/s (10485760) limit on reading to the device maj:min
}
}
Code: Select all
testaccount1 cpuset,cpu /limit0cpu50
testaccount2 blkio /limitio
In this example we will limit CPU to testaccount1, and we will limit storage I/O to testaccount2 .
Then run:
Code: Select all
cgconfigparser -l /etc/cgconfig.conf
cgrulesengd
cgconfigparser run on each config change.
Add both cgconfigparser and cgrulesengd to some start up script (for example /etc/rc.local if you have it), in order to start cgroups after server restart.