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?

8
  • 2
    It looks like you're out of space...
    – ewwhite
    Mar 10, 2015 at 11:34
  • Write operation is working fine, but it should not use more than 10 B/s but it uses around 70 to 80 B/s Mar 10, 2015 at 11:59
  • 1
    But... You are out of disk space.
    – ewwhite
    Mar 10, 2015 at 12:05
  • I have remove the some log files after that here is my new Filesystem structure: Filesystem Size Used Avail Use% Mounted on /dev/sda1 8.9G 1.1G 7.5G 12% / none 1004M 0 1004M 0% /dev/shm But still i cant restrict to Write I/O operation Mar 10, 2015 at 13:31
  • @DivijSatra You are actually restricting the read stage to 10 MB/s not 10 B/s. Writing to /dev/zero is probably what leads to confusion about the transfer rate since dd compute this based on read and write rates and is not aware that the target file descriptor will discard the data behind the scenes, making the write operation to return very fast to the caller without actually writing any block. Mar 10, 2015 at 18:34

1 Answer 1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .