cgroups and (my)Vesta

Post Reply
User avatar
Site Admin
Posts: 934
Joined: Fri Jun 19, 2020 9:59 am
Has thanked: 8 times
Been thanked: 6 times

To install cgroups, run:

Code: Select all

apt-get update
apt-get install cgroup-tools

in /etc/cgconfig.conf put:

Code: Select all

group limit0cpu50 {
    cpu {
        # all threads collectively are allowed to work for half a second out of a total of one second
    cpuset {
        # "0,1,2,3" determines on which CPU threads it is allowed to run
        # 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
Then in /etc/cgrules.conf put:

Code: Select all

testaccount1        cpuset,cpu        /limit0cpu50
testaccount2        blkio             /limitio
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:

Code: Select all

cgconfigparser -l /etc/cgconfig.conf
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.

Post Reply