How to limit the disk IO of a lxc container?

I have been searching for a long time with the key word, “lxd limit disk IO”. The information that I found in the project is the link, https://github.com/lxc/lxd/blob/master/doc/storage.md#io-limits

I/O limits

I/O limits in IOp/s or MB/s can be set on storage devices when attached to a container (see Containers).

Those are applied through the Linux blkio cgroup controller which makes it possible
to restrict I/O at the disk level (but nothing finer grained than that).

Because those apply to a whole physical disk rather than a partition or path, the following restrictions apply:

  • Limits will not apply to filesystems that are backed by virtual devices (e.g. device mapper).
  • If a filesystem is backed by multiple block devices, each device will get the same limit.
  • If the container is passed two disk devices that are each backed by the same disk,
    the limits of the two devices will be averaged.

It’s also worth noting that all I/O limits only apply to actual block device access,
so you will need to consider the filesystem’s own overhead when setting limits.
This also means that access to cached data will not be affected by the limit.

But I still have no idea to limit disk IO.

I am looking forward for you reply, thank you.

https://linuxcontainers.org/lxd/docs/master/containers#type-disk

1 Like

Thank you.
What if I want the container to burst without limitation but be limited for averaged usage in 10 minutes?

Is it possible to know the disk io of a container for current disk IO and peaked disk IO?

Neither of those are features that the Linux kernel exposes to my knowledge.

ubuntu 18.04
zfs
LXD 3.18
I am trying to track down which specific containers are using high disk i/o. By using iotop, I get the PID 1473 which is responsible for high IO usage.
ps fauxww |grep 1473
root 1473 0.0 0.0 0 0 ? S Nov19 0:56 _ [txg_sync]
ps fauxww| grep 754
root 754 0.0 0.0 0 0 ? S Nov19 0:05 _ [jbd2/vdb-8]
1000000 32754 0.0 0.0 1568 0 pts/5 Ss+ Nov22 0:00 _ /sbin/getty 38400 console
ps fauxww| grep 8437
1000000 8437 0.0 0.0 15936 836 ? Ss Dec06 0:05 _ snapfuse /var/lib/snapd/snaps/snapd_5643.snap /snap/snapd/5643 -o ro,nodev,allow_other,suid

cat /proc/PID/cgroup
cat: /proc/PID/cgroup: No such file or directory

How can I locate the container that is using too much IO by PID?