LVM vs DIR differences?

Hello,
Im planning postgresql server in container and just to be sure in this…is there any performance difference between lvm and dir storage driver for running DB?
Thx.

Cmon, nobody?

Hi,
If you have to test which one is better you can use the incus tool which is incus-benchmark in your environment, but in general every file system better than the dir filesystem because of flexibility and give much more features. You can also consider zfs file system as well.
Regards.

Hi, thx for hint. I understand your points, but I would like answer from somebody who running real world production DBs like mariadb or postgres in lxc and their opinion or reasoning for lvm or dir. Considering scenario with running this setup on public VPS with single virtual disk.
Regards.

For containers, both of them will use a standard filesystem for your database instance, that could be EXT4 or XFS. The difference between the two is not really that much for most uses cases (this come with specific usages).

LVM brings a bit more flexibility, it allows for native snapshots (can be useful for backups like you can do with large MongoDB instances), however they can be space consuming if not using a thin-pool. LVM can also brings a small performance hint since it add an abstraction layer between your disk and your filesystem, you should accomplish benchmarks to validate your requirements.

I’ve run a number of MySQL, MongoDB and PostgreSQL instances in production on top of LVM with XFS (not in a LXC container, only in VMs and bare-metal), for most of use-cases, it’s working nicely, so that shouldn’t change much (VM have an additional I/O layer to take in consideration through). You have some configurations that you can adjust in your DB engine for performance before playing with the underneath filesystem, you should stick with the recommendations (e.g MongoDB recommends XFS, PostgreSQL and MySQL have some nice results with XFS too).

Regarding other storage drivers, ZFS is a different beast and requires some tunings on the DB side. I didn’t have the opportunity to use it in production, but from my readings for PostgreSQL + ZFS, it requires more thinking to get it right (however it could be really useful to bring compression to PostgreSQL engine, but that’s another topic).

LVM:

  • Flexibility
  • You can apply hard space constraints without tinkering too much with filesystem quotas (nice to have in mutualized environment)
  • Snapshots can be space-consuming when not using a thin pool
  • You can measure a small performance hint for some use-cases (need to be validated)

DIR:

  • Simplest driver available, no requirements
  • Snapshots are not efficient and containers creation are a bit slow

Ok, thx for detailed info. It more or less confirm my findings…there are no real world performance advantages for using lvm over dir for my use scenario. Instead having DIR will give me a simplicity and remove additional unnesesery layer from picture.
Regards.