Xen 性能对比:Native,Dom0 和 DomU

安装和配置完 Xen 后很好奇虚拟出来的系统性能怎么样,虚拟化后性能肯定会有牺牲。VPSee 决定做个简单的测试看看性能差多少。

测试环境

测试工具:unixbench-5.1.2

Native:
CPU:Dual-Core AMD Opteron(tm) Processor 1220, 2800 MHz
内存:2 GB DDR2/667 ECC RAM
硬盘:2×500G SATA II
操作系统:CentOS 5.3

Dom0:
CPU:2
内存:1.8 GB RAM
操作系统:CentOS 5.3

DomU:
CPU:1
内存:256MB RAM
操作系统:CentOS 5.3

下载 unixbench-5.1.2 解压后,打开 Makefile,找到 GRAPHIC_TESTS = defined 一行注释掉,不进行图像测试。

vi Makefile
#GRAPHIC_TESTS = defined

测试结果


测试结果显示,Dom0 性能是 Native 的一半,DomU 性能要比 Dom0 要好很多,但是比 Native 差点。值得注意的是,unixbench 测试的是 Unix/Linux 的系统性能,测试结果不能真实反应整个应用系统的情况。拿网站性能来举例子,一个网站上 unixbench 的得分比另外一个网站高并不能说明这个网站的性能、吞吐量等比另外一个好,两码事。

CentOS 5.3 without Xen

------------------------------------------------------------------------
2 CPUs in system; running 1 parallel copy of tests

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0    8235202.1    705.7
Double-Precision Whetstone                       55.0       2328.9    423.4
Execl Throughput                                 43.0       1164.0    270.7
File Copy 1024 bufsize 2000 maxblocks          3960.0     210466.0    531.5
File Copy 256 bufsize 500 maxblocks            1655.0      60370.0    364.8
File Copy 4096 bufsize 8000 maxblocks          5800.0     607163.3   1046.8
Pipe Throughput                               12440.0     334853.0    269.2
Pipe-based Context Switching                   4000.0     101936.7    254.8
Process Creation                                126.0       9351.7    742.2
Shell Scripts (1 concurrent)                     42.4       1954.8    461.0
Shell Scripts (8 concurrent)                      6.0       1055.2   1758.7
System Call Overhead                          15000.0     985507.7    657.0
                                                                   ========
System Benchmarks Index Score                                         525.7

------------------------------------------------------------------------
2 CPUs in system; running 2 parallel copies of tests

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   16504213.3   1414.2
Double-Precision Whetstone                       55.0       4749.9    863.6
Execl Throughput                                 43.0       6095.6   1417.6
File Copy 1024 bufsize 2000 maxblocks          3960.0     184742.8    466.5
File Copy 256 bufsize 500 maxblocks            1655.0      46797.7    282.8
File Copy 4096 bufsize 8000 maxblocks          5800.0     866868.7   1494.6
Pipe Throughput                               12440.0     662493.2    532.6
Pipe-based Context Switching                   4000.0     285808.1    714.5
Process Creation                                126.0      17164.9   1362.3
Shell Scripts (1 concurrent)                     42.4       7529.2   1775.7
Shell Scripts (8 concurrent)                      6.0       1108.4   1847.3
System Call Overhead                          15000.0    1617244.7   1078.2
                                                                   ========
System Benchmarks Index Score                                         961.7

CentOS 5.3 Xen Dom0

------------------------------------------------------------------------
2 CPUs in system; running 1 parallel copy of tests

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0    9402312.2    805.7
Double-Precision Whetstone                       55.0       2383.4    433.3
Execl Throughput                                 43.0       1885.6    438.5
File Copy 1024 bufsize 2000 maxblocks          3960.0     122487.0    309.3
File Copy 256 bufsize 500 maxblocks            1655.0      23173.9    140.0
File Copy 4096 bufsize 8000 maxblocks          5800.0     417436.3    719.7
Pipe Throughput                               12440.0     109658.1     88.1
Pipe-based Context Switching                   4000.0      40729.7    101.8
Process Creation                                126.0       3201.5    254.1
Shell Scripts (1 concurrent)                     42.4       3069.5    723.9
Shell Scripts (8 concurrent)                      6.0        594.8    991.3
System Call Overhead                          15000.0    1170008.2    780.0
                                                                   ========
System Benchmarks Index Score                                         367.6

------------------------------------------------------------------------
2 CPUs in system; running 2 parallel copies of tests

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   18617644.9   1595.3
Double-Precision Whetstone                       55.0       4768.7    867.0
Execl Throughput                                 43.0       2697.3    627.3
File Copy 1024 bufsize 2000 maxblocks          3960.0      76448.4    193.1
File Copy 256 bufsize 500 maxblocks            1655.0      18974.4    114.6
File Copy 4096 bufsize 8000 maxblocks          5800.0     291612.2    502.8
Pipe Throughput                               12440.0     161302.5    129.7
Pipe-based Context Switching                   4000.0      65592.9    164.0
Process Creation                                126.0       4051.3    321.5
Shell Scripts (1 concurrent)                     42.4       4376.0   1032.1
Shell Scripts (8 concurrent)                      6.0        626.4   1044.0
System Call Overhead                          15000.0    1910358.1   1273.6
                                                                   ========
System Benchmarks Index Score                                         460.3

CentOS 5.3 Xen DomU

------------------------------------------------------------------------
1 CPU in system; running 1 parallel copy of tests

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0    9272991.2    794.6
Double-Precision Whetstone                       55.0       2385.1    433.7
Execl Throughput                                 43.0       2535.2    589.6
File Copy 1024 bufsize 2000 maxblocks          3960.0     473148.9   1194.8
File Copy 256 bufsize 500 maxblocks            1655.0     155153.3    937.5
File Copy 4096 bufsize 8000 maxblocks          5800.0    1010337.6   1742.0
Pipe Throughput                               12440.0     958236.0    770.3
Pipe-based Context Switching                   4000.0     140712.4    351.8
Process Creation                                126.0       4132.5    328.0
Shell Scripts (1 concurrent)                     42.4       3414.1    805.2
Shell Scripts (8 concurrent)                      6.0        474.1    790.2
System Call Overhead                          15000.0    1186203.4    790.8
                                                                   ========
System Benchmarks Index Score                                         714.6

评论 (10 Comments)

  1. 为什么domU的性能反而会比dom0好很多呢?

  2. @wyhao31
    dom0 只是一个比较特殊的 domU,性能主要看哪个配置高一些,如果 dom0 只有1个 CPU 256MB 内存,domU 有2个 CPU 4GB 内存,肯定 domU 性能高。其实这里不应该拿 dom0 出来比较,没啥实际意义,dom0 应该保持最小最简然后服务于 domU.

  3. @vpsee
    求教怎么修改dom0的配置呢,我是用ubuntu11.10装的xen。
    还有一个问题,每次新建一个domU,xm list显示的dom0的内存就相应的减少一些,我笔记本内存是2.5G,尝试新建一个2G内存的CPU貌似机器就卡死了,出现这样的情况正常么?是不是所有domU的内存和必须要小于机器总内存呢?

  4. @vpsee
    而且文章上面给的dom0的配置显然要比domU要好啊,为什么dom0跑分还没有domU高呢?

  5. @wyhao31
    可以看看:限制 Xen Dom0 的内存应该给 Xen Dom0 和 DomU 配置多大内存?

  6. @wyhao31
    和测试环境有关,仔细对比的话会发现,domu 的文件操作部分(File Copy)分数比 dom0 高很多,导致总分高很多,因为这里测试的 domu 是个镜像文件,放在 dom0 上,dom0 的文件系统和内存会缓存 domu 里的文件操作,所以 “欺骗” 了 unixbench 测试。还有 dom0 和 domu 的权重设置等等导致比分不利于 dom0,⋯⋯,等等因素,关于权重可以看看 让 Xen dom0 得到足够 CPU 处理 IO.

  7. @vpsee
    非常感谢。
    还有个问题,你提到了dom0的文件系统和内存会缓存domU的文件操作,这样我在domU中进行disk的benchmark测试得到的数据就不准确,有办法可以解决这个问题么?

  8. @wyhao31
    可以使用物理分区,在 dom0 上分多个分区然后让 domU 直接运行在某个物理分区上。

  9. @vpsee
    恩,看了你有篇文章是快速创建虚拟机镜像的,但那个也是基于文件镜像的,有没有在物理磁盘上(非LVM)上快速创建镜像的教程啊

  10. @vpsee
    我是这样创建物理磁盘上的虚拟机的,将打好的tar包在物理磁盘上解压,然后xm create -c XXX.conf,用pygrub启动的
    提示bootloader不返回任何数据,我修改了虚拟机的/etc/fstab中的uuid,改成实际物理磁盘的uuid,然后启动可以看到grub界面
    又提示找不到root,我又修改了虚拟机的/boot/grub/grub.cfg文件,将其中所有uuid都替换成之前修改的实际磁盘的uuid,现在启动提示:
    mount: mounting /dev on /root/dev failed: No such file or directory
    mount: mounting /sys on /root/sys failed: No such file or directory
    mount: mounting /proc on /root/proc failed: No such file or directory
    /init: line 352: can’t open /root/dev/console: no such file
    请问这是怎么回事啊?万分感谢~

发表评论