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?
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/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.