3

I am trying to restrict I/O write usage on my server using cgroups.

Here is my partition table info:

major minor  #blocks  name    
   8        0   10485760 sda
   8        1    9437184 sda1
   8        2    1047552 sda2

Here is my Filesystem structure:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       8.9G  8.4G   37M 100% /
none           1004M     0 1004M   0% /dev/shm

Here is my cgroups configuration:

mount { 
    blkio = /cgroup/blkio;      
}

group test2 {
    blkio {
        blkio.throttle.write_iops_device="";
        blkio.throttle.read_iops_device="8:0 10485760";
        blkio.throttle.write_bps_device="";
        blkio.throttle.read_bps_device="8:0 10485760";
        blkio.weight="";
        blkio.weight_device="";
    }
}

When I execute the following read command, it restrict the read operation to use only 10 B/s

dd if=file_1 of=/dev/zero

When I execute the following Write command, it is not restricting as per the configuration

dd of=file_1 if=/dev/zero

What am I missing?

1 Answers1

1

You probably sorted it out by now, but according to this blog post you need to tell dd to open the output file with O_DIRECT flag, otherwise caching kicks in and your cgroup config becomes useless:

dd of=file_1 if=/dev/zero oflag=direct