0

KVM/Qemu cache performance

There are a few different options when it comes time to set up your virtual storage backing within the KVM environment.

Your options are:

  1. No cache
  2. Direct sync
  3. Writethrough
  4. Writeback

Let’s take a look at what we get with each.

The no cache and writethrough methods both blend data safety with a different focus. The disk write cache for no cache method will allow for better write performance. The writethrough method will offer improved read performance. Writeback has both cache options enabled and will perform the best, but at the cost of data safety. Loss of power or a system lockup will result in data that was in the buffers to be lost. While journaling and copy-on-write based filesystems will reduce the likelihood of inconsistent date leading to filesystem corruption, certain applications may have issues with dataloss of this type. Databases, for instance, will have told themselves that those transactions were flushed to storage and will expect those blocks to have been written. For these sensitive applications directsync will be the safest. Note that directsync can still be fast if you have caching done at another level. A hardware RAID controller, for instance, will allow for safe write caching when paired with a battery.

Below are some testing results for a large array of disks on software RAID. We have the four methods benchmarked at small 4k files and sequential transfer for queue depths of 1 and 32.

And we can see performance that tracks our predictions. Writethrough beats no-cache in reads. No-cache comes back and beats writethrough in writes. Writeback absolutely dominates both as it tells the application that data has been written as soon as it hits a cache.

kyle

Leave a Reply