Best Linux filesystem for MariaDB ?

How do you choose the best Linux filesystem for your MariaDB server? The primary factors to look at are data integrity, performance, and ease of administration. Data integrity tops the list because fixing a corrupted database is even less fun than it sounds, and filesystems play a key role in data integrity. Performance is important because faster is better and time is money, and ease of administration matters for the same reasons as performance.

The short answer to the question of which is the best filesystem for a MariaDB server is ext4, XFS, or Btrfs. Why those three? All are solid enterprise journaling filesystems that scale nicely from small to very large files and very large storage volumes.

XFS Btrfs ext4
Max. filesystem size 8 EB 16 EB 1 EB
Max. file size 8 EB 16 EB 16 TB

All three are included in the mainline Linux kernel and all have good community support. openSUSE, Red Hat, and Oracle Unbreakable Linux all support ext4. openSUSE and Oracle fully support Btrfs. Red Hat 6 and 7 include Btrfs as a technology preview, but Red Hat does not yet consider it ready for production systems. If you’re running any other Linux distribution, you can use any of the three.

XFS is a mature enterprise filesystem inherited from the IRIX operating system, which was a Unix variant for Silicon Graphics MIPS hardware. XFS was ported to Linux in 2002, so it has had 12 years of real-world use and improvements. Ext4 is probably the final evolution of the ext filesystem (which started with ext, then ext2, ext3, and now ext4). It is destined to be replaced by Btrfs as the default Linux filesystem.

Btrfs is a big leap past ext4 and XFS because it supports features such as:

  • Copy-on-write
  • Subvolumes, snapshots, and rollbacks
  • Online defragmentation
  • Space-efficient packing of small files
  • Shrink and grow storage volumes
  • Checksums on data and metadata
  • Incremental backup
  • Live deduplication
  • Scrub process for repairs on live filesystems
  • Built-in RAID 0, 1, and 10, plus beta support for 5 and 6

And lots more, all for ensuring data integrity, maximum uptime, and fast flexible storage management and administration. You can replace LVM and RAID with Btrfs. However, Btrfs is still under heavy development, so the cautious approach is to use it when you’re running openSUSE or Oracle Linux, and stick with ext4 and XFS on any other Linux distribution.

Trying to figure out which filesystem gives the best performance may be fun, but the filesystem won’t make a large difference in the performance of your MariaDB server. Your hardware is the most crucial factor in eking out the most speed. Fast hard drives, discrete drive controllers, lots of fast RAM, a multi-core processor, and a fast network have a larger impact on performance than the filesystem. You can also tailor your MariaDB configuration options for best performance for your workloads.

No matter which filesystem you’re running, mount it with the noatime option, to avoid recording every time a file is accessed, which is a performance drain with little benefit. Other possible tweaks vary according to the filesystem and hardware; for example, if you have persistent write caches (with their own battery backups), or you have write-caching disabled, then use the nobarrier mount option on XFS and barrier=0 on ext4. This disables the filesystem write barriers, which are designed to improve data integrity by ensuring correct on-disk ordering of journal commits. They also incur a performance hit by making regular write cache flushes. It’s usually best to mount Btrfs with the nodatacowoption, disabling copy-on-write, because COW causes fragmentation, dish thrashing, and CPU and RAM spikes when you have a lot of random writes.

There aren’t many other possible filesystem performance tweaks, so your performance optimization energy is better spent tuning MariaDB itself and investing in good hardware.

  • Ask Question