1. 從費用上比較
http://www.path8.net/tn/archives/4994
收費和免費:
- xen 和 kvm 都是開源免費的虛擬化軟件。
- vmware 是付費的虛擬化軟件。
- hyper-v 比較特別,是微軟windows 2008 R2附帶的虛擬化組件,如果你買了足夠的授權,hyper-v(包括hyper-v 2008 core)都可以免費使用。
因此:
- 如果是vmware或hyper-v虛擬windows系統,不管是虛擬化軟件本身,還是其中的子系統,都要支付許可費用。
- 如果是vmware或hyper-v虛擬linux,虛擬化軟件本身要支付許可費用,子系統可以用linux來節省成本。
- 如果是xen或kvm虛擬windows,其中的子系統要支付許可費用。
- 如果是xen或kvm虛擬linux,那么虛擬化軟件本身和其中的子系統無需產生任何費用。
結論:
- 虛擬 windows,在有授權的情況下,建議使用 hyper-v;在沒有授權的情況下,虛擬windows,建議使用 KVM
- 虛擬 linux,建議使用 xen,如考慮到需要降低管理維護和學習成本,建議使用kvm。
2. 從性能上比較
虛擬windows,如果都能得到廠商的支持,那么,性能優化可以不用擔心。這幾款軟件全都能達到主系統至少80%以上的性能(磁 盤,CPU,網絡,內存),這時建議使用 hyper-v 來虛擬windows,微軟自身的產品,虛擬windows是絕對有優勢的。
2.1 I/O 比較
(來自 http://blog.csdn.net/babyfacer/article/details/21107513)
如果是虛擬 linux,建議:
- 首先使用 xen,支持linux的半虛擬化,可以直接使用主系統的cpu和磁盤及網絡資源,達到較少的虛擬化調度操作,可以達到非常高的性能,但xen操作復雜,維護成本較高。
- 其次我們推薦kvm來虛擬linux,linux本身支持kvm的virtio技術,可以達到少量的虛擬化調度操 作,得到較高的系統性能。
- 不推薦使用hyper-v來虛擬linux,太多的不兼容性導致linux基本無法在hyper-v上跑。
2.2 性能測試報告
http://linux.cn/article-3496-1.html
本測試使用裸機作為虛擬服務測試的基准設備。在不跑虛擬機的情況下,兩台裸機的性能偏差不會大於0.51%
在幾乎所有測試中,KVM 的性能相比宿主機而言下降了1.5%以內,只有兩項測試例外。第一個是 7-zip 壓縮,比宿主機慢了 2.79%。第二個就奇怪了,我們搭了一個郵件服務器,用 PostMark 測試其性能,結果表明 KVM 竟比宿主機快了4.11%。然后我在兩台服務器中重新跑了幾遍 PostMark 測試,結果性能差異基本不變,浮動都在最初測試結果的1%以內。由於我對 virtio 的內部機制沒有很深的理解,我只能在以后再對這個怪現象進行進一步了解。
Xen 的性能相對宿主機而言差異就比較大了。有3項測試性能下降在2.5%以內,剩下的性能下降率都是 KVM 的2~4倍。PostMark 測試的性能比 KVM 慢了14.41%,這結果令我大吃一驚。重新跑了下測試,性能差還是幾乎不變,浮動都在最初結果的2%以內。KVM 表現最好的 CPU 測試:MAFFT 對齊測試,是 Xen 表現倒數第二差的。
現在奉上一個簡短得總結表:
Best Value | Bare Metal | KVM | Xen | |
---|---|---|---|---|
C-Ray | lower | 35.35 | 35.66 | 36.13 |
POV-Ray | lower | 230.02 | 232.44 | 235.89 |
Smallpt | lower | 160 | 162 | 167.5 |
John the Ripper (Blowfish) | higher | 3026 | 2991.5 | 2856 |
John the Ripper (DES) | higher | 7374833.5 | 7271833.5 | 6911167 |
John the Ripper (MD5) | higher | 49548 | 48899.5 | 46653.5 |
OpenSSL | higher | 397.68 | 393.95 | 388.25 |
7-Zip | higher | 12467.5 | 12129.5 | 11879 |
Timed MAFFT Alignment | lower | 7.78 | 7.795 | 8.42 |
CLOMP | higher | 3.3 | 3.285 | 3.125 |
PostMark | higher | 3667 | 3824 | 3205 |
如果需要完整數據,請查看Goole Docs 電子表格。
結論
基於上面的測試環境,KVM 的性能損耗幾乎都在2%以內,Xen 則在十多項測試中有3項損耗在2.5%以內,而其他幾項損耗都在5~7%之間。雖然 KVM 在 PostMark 測試中性能表現優異,但這是眾多測試中僅有的一項 I/O 測試,如果想證明 KVM 確實在 I/O 處理方面很強悍,就需要更多測試。
2.3 更多的測試報告
http://www.phoronix.com/scan.php?page=article&item=intel_haswell_virtualization&num=1
https://blog.xenproject.org/2011/11/29/baremetal-vs-xen-vs-kvm-redux/
http://www.infoq.com/cn/news/2014/09/kvm-vs-xen
http://flymanhi.blog.51cto.com/1011558/1112363
在經過綜合測試后,不論是單個parallel還是兩個parallel,xen的跑分測試都比kvm要好。
http://blog.chinaunix.net/uid-20662820-id-4514947.html
三種虛擬化性能比較 LXC>>KVM>>XEN (由於LXC使用cgroup機制,其性能損壞基本為0。)
三種虛擬化隔離比較 XEN>>KVM>>LXC (LXC只能虛擬化linux)
三種虛擬化內存利用率 LXC>>KVM>>XEN (由於LXC共用內核,內存利用率最高;其他兩種方案每個虛機都需要單獨的操作系統占用一部分內存空間。)
http://www.os-easy.com/News/2014-10/526.html
從運算性能和磁盤負載角度來說Linux KVM不失為最快的虛擬化解決方案。相比之下,VirtualBox在測試中排名第二,而Xen在HVM模式下的虛擬化表現最差。
綜上:比較有意思的是這些測試報告的結論都不太一樣甚至是相反的。
3. 產方支持
如果以上產品我們不打算買廠商支持,其中vmware和hyper-v,是不建議使用的,主要是授權問題。
這時就剩下kvm和xen了,如果虛擬windows,建議使用 kvm,我們可以從 redhat那里免費拿到針對 windows 優化過的磁盤和網絡的驅動 程序,可以達到較高的性能(幾乎與hyper-v性能持平)。
而xen的 windows 優化驅動不是那么容易就能拿到的(由於redhat以后不支持 xen了,看看novell是否放水了,呵呵,就開放程度上來講,redhat要好於novell)。
4. 特性比較
http://blog.csdn.net/babyfacer/article/details/21107513
Attribute | Zones | Xen | KVM |
---|---|---|---|
CPU Performance | high | high (with CPU support) | high (with CPU support) |
CPU Allocation | flexible (FSS + “bursting”) | fixed to VCPU limit | fixed to VCPU limit |
I/O Throughput | high (no intrinsic overhead) | low or medium (with paravirt) | low or medium (with paravirt) |
I/O Latency | low (no intrinsic overhead) | some (I/O proxy overhead) | some (I/O proxy overhead) |
Memory Access Overhead | none | some (EPT/NPT or shadow page tables) | some (EPT/NPT or shadow page tables) |
Memory Loss | none | some (extra kernels; page tables) | some (extra kernels; page tables) |
Memory Allocation | flexible (unused guest memory used for file system cache) | fixed (and possible double-caching) | fixed (and possible double-caching) |
Resource Controls | many (depends on OS) | some (depends on hypervisor) | most (OS + hypervisor) |
Observability: from the host | highest (see everything) | low (resource usage, hypervisor statistics) | medium (resource usage, hypervisor statistics, OS inspection of hypervisor) |
Observability: from the guest | medium (see everything permitted, incl. some physical resource stats) | low (guest only) | low (guest only) |
Hypervisor Complexity | low (OS partitions) | high (complex hypervisor) | medium |
Different OS Guests | usually no (sometimes possible with syscall translation) | yes | yes |
更多的特性比較:
http://en.wikipedia.org/wiki/Operating-system-level_virtualization#Implementations
Mechanism | Operating system | License | Available since/between | Features | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
File system isolation | Copy on Write | Disk quotas | I/O rate limiting | Memory limits | CPU quotas | Network isolation | Nested virtualization | Partition checkpointing and live migration |
Root privilege isolation | ||||
chroot | most UNIX-likeoperating systems | varies by operating system | 1982 | Partial[5] | No | No | No | No | No | No | Yes | No | No |
Docker | Linux[6] | Apache License 2.0 | 2013 | Yes | Yes | Not directly | Not directly | Yes | Yes | Yes | Yes | No | No |
Linux-VServer (security context) |
Linux | GNU GPLv2 | 2001 | Yes | Yes | Yes | Yes[7] | Yes | Yes | Partial[8] | ? | No | Partial[9] |
lmctfy | Linux | Apache License 2.0 | 2013 | Yes | Yes | Yes | Yes[7] | Yes | Yes | Partial[8] | ? | No | Partial[9] |
LXC | Linux | GNU GPLv2 | 2008 | Yes[10] | Partial. Yes withBtrfs. | Partial. Yes withLVM orDisk quota. | Yes | Yes | Yes | Yes | Yes | No | Yes[10] |
OpenVZ | Linux | GNU GPLv2 | 2005 | Yes | No | Yes | Yes[11] | Yes | Yes | Yes[12] | No | Yes | Yes[13] |
Virtuozzo | Linux,Windows | Proprietary | July 2000[14] | Yes | Yes | Yes | Yes[15] | Yes | Yes | Yes[12] | ? | Yes | Yes |
Solaris Containers(Zones) | Solaris,OpenSolaris,Illumos | CDDL | February 2004 | Yes | Yes (ZFS) | Yes | Partial. Yes with Illumos.[16] | Yes | Yes | Yes[17] | Partial. Only when top level is a KVM zone (Illumos) or a kz zone (Oracle) | No[18] | Yes[19] |
FreeBSD Jail | FreeBSD | BSD License | 1998 | Yes | Yes (ZFS) | Yes[20] | No | Yes[21] | Yes | Yes | Yes | No | Yes[22] |
sysjail | OpenBSD,NetBSD | BSD License | No longer supported, as of March 3, 2009 | Yes | No | No | No | No | No | Yes | No | No | ? |
WPARs | AIX | Proprietary | 2007 | Yes | No | Yes | Yes | Yes | Yes | Yes[23] | No | Yes[24] | ? |
HP-UX Containers (SRP) | HPUX | Proprietary | 2007 | Yes | No | Partial. Yes with logical volumes | Yes | Yes | Yes | Yes | ? | Yes | ? |
iCore Virtual Accounts | Windows XP | Proprietary/Freeware | 2008 | Yes | No | Yes | No | No | No | No | ? | No | ? |
Sandboxie | Windows | Proprietary/Shareware | 2004 | Yes | Yes | Partial | No | No | No | Partial | Yes | No | Yes |