Zstandard compression for XCP-ng

Features Dec 19, 2018

Current VM export/import compression is handled via GZIP, which is horribly slow and mono-threaded. Good news is: we managed to add a better compression algorithm, and the results are awesome!


  • Zstd compression is now available and you only need to do an update an restart the toolstack!
  • Since Xen Orchestra 5.31 is available - you can use zstd compression for your backup and benefits from 6 times faster backup speed!

A huge historical bottleneck

Since XenServer introduced compression for VM export/import (a bit less than 10 years ago), it suffered a large performance penalty. To a point where NOT using compression was a lot faster than using it. The only good part was reducing the exported file size (roughly shrinking by 40% against a non-compressed export).

We (Xen Orchestra team) reported this problem and proposed a solution more than 2 years ago. Sadly, it ended up in the Citrix wish list without any progress. But since we decided to fork XenServer, we now had the opportunity to do it ourselves! But which alternative compression algorithm could we use?

Zstandard: a fantastic compression algorithm

Zstandard  (zstd) is a real-time compression algorithm, providing high compression ratios. It offers a very wide range of compression / speed trade-off, while being backed by a very fast decoder. You can learn more about it and see some benchmarks on the official website: https://facebook.github.io/zstd/

Basically, it eats zlib, lzma and obviously GZIP for breakfast. Sounds like a good alternative, eh? But before doing a real implementation, we did some benchmarks, piping the uncompressed VM export into the zstd program. Do you want to see the result? Okay here it is:

The new compression in XCP-ng is 11,5 times faster than the XenServer default compression, and still delivers a 10% smaller file.

Against uncompressed export, it's still faster, but more interestingly 50% smaller. In short, best of both worlds. Neat!

You can also compare the same export using Xen Orchestra stats view, I guess it speaks for itself:

Upstream first

The next step was to get further than just a proof of concept: integrating this code into the XAPI (into xen-api-libs-transitional to be exact), and precisely making a pull request that also improves the existing code to allow more generic compression solutions in the future. We did it, and it was merged! (a big thanks to our reviewers). This is the first non-Citrix contribution into the XAPI, and we are proud of that!

By going upstream first, we keep pushing everything in Open Source, and Citrix can decide (or not) to use it for the next XenServer version, while it will be available in XCP-ng as a simple update.

Exposing the new compression

Now that we added the feature, we also need to expose it into the API. Especially in Xen Orchestra, because basic backups are using the export/import mechanism. Feel free to read the detailed Xen Orchestra blog post about it.

Example of compression selector for Xen Orchestra backup

Just keep one number in mind: against uncompressed exports, this allows backups that are twice as fast ! (because the exported file size is half the size).


Since it's actually coded and merged in XAPI, the only thing left is a bit of packaging and QA work before a production update in XCP-ng. It will land first in testing RPM repositories. Expect this feature to be available really soon in your XCP-ng 7.6. Stay tuned!


Olivier Lambert

Vates CEO & co-founder, Xen Orchestra and XCP-ng project creator. Enthusiast entrepreneur and Open Source advocate. A very happy Finnish Lapphund owner.