Web应用(WordPress)在KVM虚拟机中的性能测试

目前,有很多的应用运行在虚拟机中,其中有很大一部分是Web程序,那么对一个虚拟机的性能做综合评估时,Web程序应当是必须纳入评估范围的。本文以最流行的开源博客系统——WordPress(本博客也是用它来搭建的)来做为本次测试使用的Web应用,测试它在KVM虚拟机以及在嵌套虚拟化的第2层虚拟机中的性能表现。

本次测试使用了Intel最新的硬件平台Haswell,它有EPT和ShadowVMCS的支持。
在测试数据归一化后,WordPress在KVM虚拟化环境中的表现性能如下图所示(WordPress主页的测试):

基本结论(当然只是对本实验而言):
1. KVM虚拟化效率还是比较高的,即使是在第二层客户机中的表现也不错;
2. 普通客户机效率为原生系统的91%,第二层客户机可以达到原生系统的67%;
3. virtual EPT的功能让Web程序运行效率提高了1倍左右;
4. VMCS shadowing 特性也能带来大约10%~20%的性能提高。
注:virtual EPT的patch还没有加入到upstream中(估计Kernel 3.11会有这些patch),本实现采用了线下手动打上相应的patch;Shadow VMCS是Intel Haswell CPU才引入的新特性(老的平台是没有)。

一些测试过程的具体细节和配置,请参考下面的内容(曾用英文简单写过,就不用中文再写了,大家有兴趣就将就看一下吧):

1. Main method: I used the target test system as the WordPress server system, and used JMeter (in the same 1000M LAN) as the client to generate a great amount of HTTP requests to the WordPress site and to collect/measure the response data from WordPress.

2. Below is the software stack. (BTW, the hardware is a Haswell mobile box.)
KVM: kvm.git next branch with kernel 3.9.0-RC3 (with offline vEPT patches)
QEMU: 1.4.50
guest OS: RHEL6.4 (with 4vCPUs and 4GB memory)
Web Server: Apache (httpd-2.2.15-26.el6.x86_64.rpm)
Database: MySQL (mysql-server-5.1.66-2.el6_3.x86_64.rpm)
Web App: WordPress v3.5.1
JMeter (a client on another machine): JMeter v2.9

3. WordPress Application: (If someone is kind of familiar with Apache, MySQL and PHP, it’s very easy for him to set up the WordPress website.)
The following link is a simple and clear guide for installing WordPress. (I don’t want to write duplicated docs about this.)

http://codex.wordpress.org/Installing_WordPress

4. test client (load generator): JMeter (JMeter is a widely used open-source Web performance test tool which is written in Java.)
If I list the details about how JMeter works, it’ll be too complicated. Here’s its website: http://jmeter.apache.org/ , which has docs about this tool.

5. test cases: JMeter measured the response time and thoughput from the WordPress sever side. (we collected data for response time.)
case #1: the main page which should be the most likely visited page in the WordPress blog system.
case #2: a static image (with the size for about 300Kbytes)
case #3: a login page and login action
case #4: the administrator’s main page
For each test case, I used 20 client threads to interacting with the WordPress server simultaneously.
The CPU utilization is 50%~70% and load is 1~4 in the target system.

6. test result:
There’s significant performance improvement for case #1 but not much improvement for case #2~4 when adding vEPT and VMCS Shadowing.
So I only used the data of case #1 in my formal report.
The following is the detailed data in the WordPress testing. (response time in milliseconds: the smaller, the better.)

注:在这个图表中数据表示的是响应时间,数值是越小越好。后台登录页面和管理页面的影响时间超过5秒钟,主要是由于WordPress的设计问题(当然一般只有管理员等才会登录),与是否虚拟化都没有啥关系(不过也能看出virtualEPT和ShadowVMCS带来的一些性能提高)。

关于检查 virtual EPT 和 VMCS shadowing 特性的方法:

重建本文档时,附带以前原文档中的评论:

lcy 六 2nd, 2013 22:39 回复 | 引用 | #1
请问楼主在测试中THP是否打开?

master
嗯,THP都是打开的~ 影响性能的因素太多了,性能调优也是一些很具体的事情,所以没有将相关的配置一一列出来。

lcy 六 4th, 2013 09:47 回复 | 引用 | #3
嗯,楼主能否尽量列些与性能相关的设置参数,谢谢!

master
呃~ 我觉得这个得看你具体想在客户机中运行什么程序,因为不同程序可能对某方面(如CPU、内存、网络、磁盘等)比较敏感~ 我觉得一般来说,影响比较大的因素有:EPT、Huge page (包括THP)、使用中断方式、磁盘的使用方式、网络的使用方式等,具体在本博客中提到的嵌套虚拟化的部分,virtual EPT、VMCS shadowing等也有较大的影响。

master

Stay hungry, stay foolish.

One Comment

  1. EPT功能怎么打开啊?是在bios里还是宿主机的系统里设置啊?

AaNing进行回复 取消回复

邮箱地址不会被公开。 必填项已用*标注

*