What is the best way to improve file I/O performance in containers?

I have been tasked with improving file I/O performance on a certain embedded system running a flavor of Android. It has been set up with LXC by someone who is not me.

The container storage is mounted through a loop device and eventually ends up as files in a subdirectory of the same filesystem (f2fs) mounted by the host. Each container maps to its own subdirectory.

I did some tests and found this to be around 20% slower than access to the same filesystem on the host.

I also confirmed that mounting a new partition directly (for example /dev/sda6, unused elsewhere) gives host-level performance.

So my question: would creating separate storage partitions for each container be a sane thing to do, or is there a much easier way to improve performance without fragmenting device storage?

Any advice would be appreciated!

1 Like

Yeah, there can be quite a bit of overhead from having to write through another filesystem every time. You may be able to use LVM LVs rather than real partitions, allowing for easier resizing and keeping a pretty similar access speed.

Hi, thanks for the reply.

I’m starting to think I’m making this too hard… Maybe I should just mount the block device of the single, large partition somewhere out of the way, then bind mount a sub-tree of it as /data. Like have /data_container_1/2/3/… on /dev/sda5, mount /dev/sda5 in each container under /mnt/private_root, then bind mount /mnt/private_root/data_container_? to /data.

It seems funny to have multiple “machines” all mounting the same partition/fs, but at the end of the day there is only a single flash storage controller that gets shared.

Hmm… I guess I’ll have to try a few different ways and measure performance.

Now if I only had a working lxc client or some idea of how/where the containers mount filesystems.