140: Fast, Easy, and Efficient

Here’s OpenZFS Mastery on tuning to support databases.

Every DBA wants fast, easy, and efficient replication, snapshots, clones, tunable caches, and pooled storage. While ZFS supports all this by default, you can tune it to make your databases fly.

Databases usually consist of more than one type of file, each with different characteristics and usage patterns that require different tuning. We’ll discuss MySQL and PostgreSQL in particular, but the principles apply to any database software.

The most important tuning you can perform for a database is the dataset block size, through the recordsize property. The ZFS recordsize for any file that might be overwritten needs to match the block size used by the application.

Tuning the block size also avoids write amplification. Write amplification happens when changing a small amount of data requires writing a large amount of data. Suppose you must change 8 KiB in the middle of a 128 KiB block. ZFS must read the 128 KiB, modify 8 KiB somewhere in it, calculate a new checksum, and write the new 128 KiB block. ZFS is a copy-on-write filesystem, so it would wind up writing a whole new 128 KiB block to change that 8 KiB. You don’t want that. Now multiply this by the number of writes your database makes. Write amplification eviscerates performance.

If you sponsor OpenZFS Mastery today, you’ll get a copy of the mostly-complete draft that went out to sponsors and tech reviewers.

Leave a Reply

Your email address will not be published. Required fields are marked *