39

What is faster on the same hardware, Xen or KVM?

I'm trying to pick-up a virtualization technology to work, which gives the best performance.

There are some benchmarks here that I found on the subject: http://virt.kernelnewbies.org/XenVsKVM

They show KVM as a winner, with significant difference in performance - which goes against the idea that KVM is a type-2 hypervisor, and by definition it should be slower than Type-1 hypervisors (like Xen) - or at least that what the articles on the web say.

Any idea on the subject?

Peter Mortensen
  • 2,319
  • 5
  • 23
  • 24
SyRenity
  • 3,159
  • 11
  • 55
  • 79
  • 1
    That comparison seems pretty bad as it compares KVM+1xVM and Xen+1VM... What is the point of having virtualization if you only have on VM ? – Antoine Benkemoun Jul 17 '09 at 06:29
  • KVM is NOT a type 2 hypervisor. It is definitely type-1, and it is definitely closer to the hardware than Xen is. So yes, given the exact same conditions, KVM should perform better, especially with the modern virtIO drivers – dyasny Jun 04 '10 at 19:51
  • 3
    If you're reading this in 2017 (someone did a trivial edit to the question) then realise that this question and its answers are **EIGHT YEARS OLD**. KVM vs Xen landscape is very different now. – thomasrutter Sep 17 '17 at 23:37

7 Answers7

35

That benchmark is only comparing the speed of the native OS to a single guest OS. It is hardly a real-world test. I don't think I would put much weight on it. Most of the KVM camp argues that Xen requires too many interrupts and hops between kernel and user space, but from most of the more real-world benchmarks that I've seen that hasn't really been realized and Xen seems to be a bit faster than KVM.

Sorry I don't have a link to back that up handy. But I will say that KVM is improving fast and seems to be catching up on feature set and stability quickly.

As to which approach is better. The Xen camp will argue that a true light-weight hypervisor is required virtualization to be secure and fast. Xen is also starting to be supported in firmware by some vendors which is also nice. The KVM camp will argue that KVM is simpler and that Linux is capable of being a good hypervisor.

In the end it's still unclear which direction will ultimately win. Xen certainly has a head start and already has a nice market share. But it's not in the mainline kernel, yet. Hopefully that will change soon and there has certainly been a lot of talk about this on the kernel list in the past few months. Red Hat is in the KVM camp now and will be pushing it as the virtualization platform of choice. Red Hat Linux 5.4 which is coming out shortly will be the first to include it. So that will likely attract shops that haven't rolled out or committed to a virtualization platform yet.

As far as tools go, both Xen and KVM use libvirt and QEMU and the tools associated with them. So they share many of the same tools such as virt-manager.

We use Xen at work, and it works well for us. But I've been looking into KVM due to some USB forwarding and PCI passthrough issues I've been unable to resolve with Xen. I'm not sure KVM is any better at this, but I guess I'll find out once I try it. One thing I have noticed in researching my USB issues is that KVM's documentation is more assessable and organized compared to Xen's. But there is no perfect virtualization platform so you'll need to figure out what makes sense for you.

Axel Latvala
  • 201
  • 1
  • 4
  • 12
3dinfluence
  • 12,409
  • 2
  • 27
  • 41
  • Any idea if same will hold in future? As Redhat 5.4 is coming soon with native KVM support, I'd like to know what I won't have to switch to KVM from Xen in 1/2 year. Thanks. – SyRenity Jul 18 '09 at 18:06
  • 1
    I can't make any predictions on what the future holds. But neither of these platforms are going to disappear. RedHat has said that they are committed to supporting Xen as well as KVM. Only time will tell how this one plays out. But I wouldn't worry about having to change in 6 months. Maybe in a few years there will be a clear leader in the opensource virtualization platforms. – 3dinfluence Jul 18 '09 at 23:43
  • Interesting you note moving to KVM for USB support - I've just had to think about moving away due to the lack of USB 2.0 support! I'm guessing from your post that Xen isn't going to be much better. – jkp Nov 15 '10 at 18:22
  • 1
    @jkp I was waiting for a few other pieces of our infrastructure to be replaced. Which was just completed. So in the coming weeks I may be able to look closer at KVM. However in my case the hardware doesn't support IOMMU (VTd). So I'm not sure if moving to KVM will help. XEN requires IOMMU support for pci passthrough. But KVM supports USB and PCI element passthrough using libvirt. So I'm hoping that will work without IOMMU. Right now under Xen the only way that I know to pass USB through is pass the USB PCI controller through but that information may be dated at this point. – 3dinfluence Nov 15 '10 at 18:36
  • 1
    @3dinfluence: I think you might misunderstand how USB and PCI support is implemented - libvirt doesn't do any of these things itself, it only provides a way of configuring the underlying capabilities of the VM hypervisor. In this case the capabilities are provided by a combination of the KVM kernel modules and the Qemu userspace code. – jkp Nov 16 '10 at 09:31
  • @jkp No I'm aware of that but since I use libvirt to define and manage my VM's I'll be using the libvirt interface, xml files, to set this up. KVM via libvirt does allow for passing USB and PCI devices through without IOMMU. On http://libvirt.org/formatdomain.html#elementsUSB you'll notice that only KVM supports this libvirt feature. I'm sure it's using some Qemu code to make that happen which is why it's not supported under XEN. – 3dinfluence Nov 16 '10 at 15:12
  • ahhhh, im with you now. yeah, I used to use libvirt and virsh but it was to cumbersome, then I moved away but now I'm back with virt-manager over forwarded X. Got tired of maintaining my own scripts and config files :) – jkp Nov 16 '10 at 17:15
  • @3dinfluence You said: "But I've been looking into KVM due to some USB forwarding and PCI passthrough issues I've been unable to resolve with Xen. I'm not sure KVM is any better at this but I guess I'll find out once I try it." Do you have any updates on this? – Yamaneko May 07 '14 at 22:21
7

I personally would choose virtualisation based on usability, support, reliability and suitability for the virtual machines you are using.

Xen networking data transfer rates seem to be as good as real hardware, but I've also had some battles with Xen and vLans and multiple Ethernet cards. I have no experience of KVM, but I would also suggest that you consider VMware ESX(i) as well.

Peter Mortensen
  • 2,319
  • 5
  • 23
  • 24
Michael Shaw
  • 663
  • 4
  • 9
6

You will find very interesting information on the subject in the following presentation: Quantitative Comparison of Xen and KVM

The person who did this is a Xen expert, but the comparison seems pretty fair.

Peter Mortensen
  • 2,319
  • 5
  • 23
  • 24
Antoine Benkemoun
  • 7,314
  • 3
  • 41
  • 60
  • Thanks for the presentation, reading it seems that while Xen is tops on CPU and Network IO, KVM tops on HD IO. But reading this numbers (http://virt.kernelnewbies.org/XenVsKVM), seems that KVM won hands up on every comparison. Any idea where is the truth? :) – SyRenity Jul 18 '09 at 18:20
  • I believe my presentation seems more realistic. It runs more then one VM at at time. The testing protocol seems closer to reality. – Antoine Benkemoun Jul 19 '09 at 09:38
  • +1 Interesting presentation! Xen seem to have better isolation. – Jonas Mar 05 '11 at 15:48
5

FWIW: The answer depends entirely on your needs, now and in the future.

Yes, I know that's an unhelpful answer. Unfortunately, it's true. Your choice of virtualisation will affect pretty much everything you do afterwards, so you need to ask yourself a few questions.

(1) Is the difference between 97% of native performance and 96% of native performance (figures plucked out of the air) really that important to you?

(1a) If one does better with HD access (which really implies that you're either using a whacking great database, or you can't afford the extra RAM), and the other does better with networking, which is more important to you?

(2) Are you confident using the tools provided with either solution?

(3) Does the fact that one is (sort of) native to recent Linux kernels, and the other one not, make a difference?

(3a) Do you now, or have you ever been ... er ... will you ever need to run a different OS under virtualisation? It doesn't have to be Windows. It might be FreeBSD, or even Haiku, or whatever. (Xen probably wins here, but I suggest you check.)

Looking at the big picture, I see KVM as Linux' answer to Solaris zones. (I'd rather have Solaris zones, but I see the parallel.) I see Xen as a mature hypervisor technology with support for multiple OSes, but then if you don't need multiple OSes, that doesn't matter so much.

To be absolutely honest, you can't go far wrong either way (given caveats above). I prefer Xen, because I went to Cambridge; but then, if I worked for RH, I'd probably prefer KVM.

5

I might be going out on a limb here, but I don't think that raw performance is the most important metric when it comes to technologies like this.

I think that usability and interface is important, as well as tools to support a reliable infrastructure. It seems to me that Xen has a far more robust set of existing applications that support it than does KVM. That might not be the case, as I have no evidence to back it up.

Whatever you go with, decide what the best solution is for you, and look at the entire package, not just the raw performance.

Matt Simmons
  • 20,218
  • 10
  • 67
  • 114
2

A lot of the difficulty or ease in setting up KVM is distribution-dependent. Picking a Xen-centric distribution will make Xen easier. Picking a KVM-centric distribution will make KVM easier.

The tools question is somewhat irrelevant because both use libvirt. This means you use the same management tools for both in most cases.

1

At the end of 2017, Amazon which formerly was the biggest Xen user, announced that it will use KVM for all their new C5 instance types. To the best of my knowledge, only the cloud provider SoftLayer is left as a big Xen users. Linode switched in 2015, and reported major performance improvements.

It is difficult to find realistic and up-to-date performance comparison, but there does not seem to be such a huge gap between both solutions as you might think. Depending on the use case, Xen can be even faster. KVM has other benefits, being part of the Linux kernel and embraced by RedHat, that are also relevant. For instance, this answer elaborates on why Google choose KVM for Google Compute Engine.

Still, the fact that almost all cloud providers, especially Google and Amazon, are choosing KVM over Xen is a strong argument that for typical workloads, KVM is a very good choice in terms of performance.

Philipp Claßen
  • 511
  • 1
  • 8
  • 19
  • Note: Amazon uses modified version of KVM, not a native one. And I wouldn’t say that they have typical workloads, probably they have a really heavy and uncommon workloads, imho – ALex_hha Jan 21 '18 at 21:58
  • @ALex_hha What I meant is that they have to choose a technology that works best for the applications that their customers will run. In that sense, they have to find a setup that is fast over different use cases. But I agree that there are other scenarios, like embedded systems, where Xen may comparable more favorably. – Philipp Claßen Jan 23 '18 at 20:26