Performance benchmarks: KVM vs. Xen

通过对KVM和Xen进行一系列基准测试,在大多数测试中KVM的表现接近裸金属服务器,而Xen则表现出了更大的性能变化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


https://major.io/2014/06/22/performance-benchmarks-kvm-vs-xen/


After having some interesting discussions last week around KVM and Xen performance improvements over the past years, I decided to do a little research on my own. The last complete set of benchmarks I could find were from the Phoronix Haswell tests in 2013. There were some other benchmarks from 2011 but those were hotly debated due to the Xen patches headed into kernel 3.0.

The 2011 tests had a good list of benchmarks and I’ve done my best to replicate that list here three years later. I’ve removed two or three of the benchmark tests because they didn’t run well without extra configuration or they took an extremely long time to run.

Testing environment

My testing setup consists of two identical SuperMicro servers. Both have a single Intel Xeon E3-1220 (four cores, 3.10GHz), 24GB Kingston DDR3 RAM, and four Western Digital RE-3 160GB drives in a RAID 10 array. BIOS versions are identical.

All of the tests were run in Fedora 20 (with SELinux enabled) for the hosts and the virtual machines. Very few services were left running during the tests. Here are the relevant software versions:

  • Kernel: 3.14.8
  • For KVM: qemu-kvm 1.6.2
  • For Xen: xen 4.3.2

All root filesystems are XFS with the default configuration. Virtual machines were created using virt-manager using the default configuration available for KVM and Xen. Virtual disks used raw images and were allotted 8GB RAM with 4 virtual CPU’s. Xen guests used PVHVM.

Caveats

One might argue that Fedora’s parent owner, Red Hat, puts a significant amount of effort into maintaining and improving KVM within their distribution. Red Hat hasn’t made significant contributions to Xen in years and they made the switch to KVM back in 2009. I’ve left this out of scope for these tests, but it’s still something worth considering.

Also, contention was tightly controlled and minimized. On most virtualized servers, you’re going to have multiple virtual machines fighting for CPU time, disk I/O, and access to the network. These tests didn’t take that type of activity into consideration. One hypervisor might have poor performance at low contention but then perform much better than its competitors when contention for resources is high.

These tests were performed only on Intel CPU’s. Results may vary on AMD and ARM.

Results

The tests against the bare metal servers served as a baseline for the virtual machine tests. The deviation in performance between the two servers without virtualization was at 0.51% or less.

KVM’s performance fell within 1.5% of bare metal in almost all tests. Only two tests fell outside that variance. One of those tests was the 7-Zip test where KVM was 2.79% slower than bare metal. Oddly enough, KVM was 4.11% faster than bare metal with the PostMark test (which simulates a really busy mail server). I re-ran the PostMark tests again on both servers and those results fell within 1% of my original test results. I’ll be digging into this a bit more as my knowledge of virtio’s internals isn’t terribly deep.

Xen’s performance varied more from bare metal than KVM. Three tests with Xen came within 2.5% of bare metal speeds but the remainder were much slower. The PostMark test was 14.41% slower in Xen than bare metal and I found that result surprising. I re-ran the test and the results during the second run were within 2% of my original results. KVM’s best performing CPU test, the MAFFT alignment, was Xen’s second worst.

I’ve provided a short summary table here with the final results:

If you’d like to see the full data, feel free to review the spreadsheet on Google Docs.

Conclusion

Based on this testing environment, KVM is almost always within 2% of bare metal performance. Xen fell within 2.5% of bare metal performance in three out of ten tests but often had a variance of up to 5-7%. Although KVM performed much better with the PostMark test, there was only one I/O test run in this group of tests and more testing is required before a clear winner in disk I/O could be found.

As for me, I’d like to look deeper into how KVM and Xen handle disk I/O and why their results were so different. I may also run some tests under contention to see if one hypervisor can deal with that stress with better performance.

I’d encourage readers to review the list of benchmark tests available in the Phoronix test suite and find some that emulate portions of their normal workloads. If your workloads are low CPU and high I/O in nature, look for some of the I/O stress tests in the suite. On the other hand, if you do a lot of audio/video transcoding, try some of the x264 or mp3 tests within the suite.

UPDATE: Chris Behrens pointed out that I neglected to mention the type of virtual machine I tested with Xen. I used PVHVM for the tests as it’s the fastest performing option for Linux guests on Xen 4.3. Keep in mind that PVH is available in Xen 4.4 but that version of Xen isn’t available in Fedora 20 at this time.


提示错误[root@localhost speccpu2017]# runcpu --config=arm64.cfg --copies=1 --threads=1 - -reportable -n 3 fprate & [1] 19484 [root@localhost speccpu2017]# SPEC CPU(r) 2017 Benchmark Suites Copyright 1995-2019 Standard Performance Evaluation Corporation (SPEC) runcpu v6612 Using 'linux-aarch64' tools Reading file manifests... read 32349 entries from 2 files in 0.13s (240098 files /s) Loading runcpu modules................. Locating benchmarks...found 47 benchmarks in 73 benchsets. Reading config file '/opt/speccpu2017/config/arm64.cfg' 1 configuration selected: Action Run Mode Workload Report Type Benchmarks -------- -------- -------- --------------- ---------------------------- validate rate refrate SPECrate2017_fp fprate Downloading update information for version check... NOTICE: Could not retrieve update metadata;got Could not connect to 'www.spec.org:80': Name or service not known ...Version check failed. A connection to the internet is useful, but is NOT required in order to run CPU2017. If one is available, several components will be checked to see if they are current. If you need to use an HTTP proxy to access the Internet, please see the 'http_proxy' entry in config.html. ---------------------------------- The run will continue in 5 seconds ---------------------------------- Reportable runs must include a 'test' run; adding to run list Reportable runs must include a 'train' run; adding to run list ------------------------------------------------------------------------------- Setting up environment for running fprate... Starting runcpu for fprate... Running "specperl /opt/speccpu2017/bin/sysinfo" to gather system information. sysinfo: r6732 of 2022-11-07 (fe91c89b7ed5c36ae2c92cc097bec197) sysinfo: ...getting basic information about kernel, users, and limits sysinfo: Getting system information for Linux... sysinfo: ...getting CPU info sysinfo: ...getting info from numactl sysinfo: ...getting memory info sysinfo: ...getting info from systemd sysinfo: ...getting power info sysinfo: ...getting system tuning info sysinfo: ...getting OS info sysinfo: ...getting disk info sysinfo: ...getting info from /sys/devices/virtual/dmi/id sysinfo: ...getting info from dmidecode Retrieving flags file (/opt/speccpu2017/config/flags/gcc.xml)... Reportable runs must include a 'test' run; adding to run list Reportable runs must include a 'train' run; adding to run list Benchmarks selected: 503.bwaves_r, 507.cactuBSSN_r, 508.namd_r, 510.parest_r, 51 1.povray_r, 519.lbm_r, 521.wrf_r, 526.blender_r, 527.cam4_r, 538.imagick_r, 544. nab_r, 549.fotonik3d_r, 554.roms_r, 997.specrand_fr Notice: Errors may not be ignored for reportable runs. Compiling Binaries Building 503.bwaves_r base mytest-64: (build_base_mytest-64.0000) [2025-07-24 08:48:41] Building 507.cactuBSSN_r base mytest-64: (build_base_mytest-64.0000) [2025-07- 24 08:48:43]
07-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值