[lxc-users] Limiting disk IO on LXD containers [solved]

Ivan Ogai lxc-users at ogai.name
Thu Jul 6 10:29:48 UTC 2017


Simos has already answered this question on 

https://discuss.linuxcontainers.org/t/limiting-disk-io-on-lxd-containers/261

I have also copied the answer on 
https://serverfault.com/questions/858873/limiting-disk-io-on-lxd-containers

In short: it works wtih ZFS and btrfs storage backend.


* Ivan Ogai <lxc-users at ogai.name> [2017-07-04 16:38]:
> Greetings LXCers/LXDers
> 
> Just in case: I have also posted this question in discuss and
> serverfault. By getting an answer here or there, I will answer the
> others of course for everyone to find them. References at the end.
> 
> 
> 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.
> 
> **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.
> 
> 
> 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 at 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**?
> 
> 
> Question references:
> https://discuss.linuxcontainers.org/t/limiting-disk-io-on-lxd-containers/261
> https://serverfault.com/questions/858873/limiting-disk-io-on-lxd-containers
> 
> -- 
> Ivan


More information about the lxc-users mailing list