Linux – Weight-based block IO control for VMs

block-devicecgroupsiokvmlinux

I use KVM to manage my virtual machines. I am trying to limit the resources provided for VMs. I am able to limit the CPU and memory allocated for VMs using libvirt/cgroups. Now I want to control the disk time allotted for each VM by applying some weights. I looked at blkio control from cgroups. Since VM is just a Linux process, I will be able to use cgroups but I am not sure whether it will work for asynchronous IO too. If not, can someone suggest a good alternative solution?

Best Answer

Blkio in cgroup terminology stands for access to I/O on block devices. It does not seem to be about regulating all the different ways software developers have at hand for I/O-related purposes.

It seems to be targeted mainly to I/O on devices, not on the way software has access to devices. It can limit the number of iops, the bandwidth or a weight with other processes, in other things. It seems that buffered write is not supported by blockio at the moment. It's in the official documentation:

Currently, the Block I/O subsystem does not work for buffered write operations. It is primarily targeted at direct I/O, although it works for buffered read operations.

If you take a look at this presentation from Linda Wang and Bob Kozdemba of Red Hat, on page 20+, you'll see that the graph is about the device bandwidth per VM, not about random vs blocking vs asynchronous I/O.

It seems there has been recent work by Red Hat to implement it directly into virsh. It has been released last week in libvirt 0.9.9. In a few months, you'll be able to do something like this in your favorite distribution:

virsh blkiotune domA --device-weights /dev/sda,250
virsh blkiotune domB --device-weights /dev/sda,750
Related Question