On a container running on a host with two disks on a mdadm RAID 1 array, I have tried without success to limit the disk IO of a LXD container named ci with:

lxc config device set ci root limits.read  30MB
lxc config device set ci root limits.write 10MB

However, when running e.g. this command on the container:

dd if=/dev/zero of=/root/testfile bs=1G count=10 oflag=direct

the result is the whole capicity of the disk, which is about 130MB/s, instead of the expected result of about 10MB/s for writing operations:

10737418240 bytes (11 GB, 10 GiB) copied, 81,3877 s, 132 MB/s

This is also confirmed by atop running on the host:

enter image description here

How can I effectively limit the disk IO of the container, so that no matter what happens on it, the host disk performance is not overcommitted?

On a second test, I run the same dd command as above at the same time on the guest and on the host, but the host is not prioritized either:

enter image description here

Some additional information:

  • Host and guest are Ubuntu 16.04
  • The server has two hard disks with equal partitions, joined in RAID 1 arrays
  • On top of the biggest RAID array the root filesystem is mounted on a LVM volume group

    root@server ~ # lvs
    LV   VG   Attr       LSize
    root vg0  -wi-ao---- 2,72t
    swap vg0  -wi-ao---- 4,00g
  • The LXD storage backend is dir

I could partitition the disk differently if that could help limiting disk IO of the container, e.g. having a RAID array dedicated to ZFS for LXD. Would that help?

  • Nice question! Just a comment regarding the readability of the question: The screenshots are a bit difficult to read. I would say using verbatim mode as in the section "root@server ~ # lvs" would be easier to read (although the colors would be lost). – Erik Sjölund Jul 18 '17 at 13:44

I/O limits work when the container filesystem is on a block device, but doesn't work on virtual devices like mdadm RAID when using an old version like 10.0.9.

After updating to version 10.15, limits works. In Ubuntu you can update with:

sudo add-apt-repository ppa:ubuntu-lxc/lxd-stable 
sudo apt-get update
sudo apt-get install lxd

For more details, see the discussion on this at https://discuss.linuxcontainers.org/t/limiting-disk-io-on-lxd-containers/261 and the open issue at https://github.com/lxc/lxd/issues/3515

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.