您好,欢迎访问一九零五行业门户网

php缓冲器:eaccelerator与xcache性能测试对比

随着php流行,php的执行效率也越来越被大家关注,可以选择的缓存器也是越来越多,从老的php-memcache到eaccelerator还有新兴的xcache。为了挑选一个合适的缓存器决定自己实测一下,看看哪个缓存器的效率更高,由于php-memcache很少有人用了现在只测试eaccele
随着php流行,php的执行效率也越来越被大家关注,可以选择的缓存器也是越来越多,从老的php-memcache到eaccelerator还有新兴的xcache。为了挑选一个合适的缓存器决定自己实测一下,看看哪个缓存器的效率更高,由于php-memcache很少有人用了现在只测试eaccelerator和xcache。硬件配置:cpu:intel 2140(双核心)内存:2g ddr667硬盘:80g(ide接口,2m缓存)
软件版本系统:mandriva 2008 free,apache-2.2.6,php-5.2.4,zendoptimizer-3.3.0,mysql-5.0.45。测试对象的版本:eaccelerator-0.9.5.2,xcache-1.2.1
eaccelerator与xcache都是手动编译安装,安装安装官方公布的安装步骤和参数,需要了解的可以登录他们的网站去看。考虑到对商业代码的支持,缓存器都安装为zend的扩展,同时两个缓存器的缓存大小都是64m(呵呵有点大一般16m就不小了)。测试的时候关于eaccelerator会测试两项,一项是默认的,一项是把eaccelerator的缓存目录放到tmpfs中,我叫他为eaccelerator的内存模式。关于tmpfs的情况可以看下这里http://lcuc.org.cn/node/304。
测试工具为ab,测试读取对象是phpmyadmin-2.11.2,discuz!_6.0.0_sc_gbk
phpmyadmin部分
测试语句为:ab -n 100000 http://localhost/phpmyadmin
不安装任何缓存器
[root@mandriva phpmyadmin]# ab -n 100000 http://localhost/phpmyadminthis is apachebench, version 2.0.40-dev apache-2.0copyright 1996 adam twiss, zeus technology ltd, http://www.zeustech.net/copyright 2006 the apache software foundation, http://www.apache.org/
benchmarking localhost (be patient)completed 10000 requestscompleted 20000 requestscompleted 30000 requestscompleted 40000 requestscompleted 50000 requestscompleted 60000 requestscompleted 70000 requestscompleted 80000 requestscompleted 90000 requestsfinished 100000 requests
server software: apache/2.2.6server hostname: localhostserver port: 80
document path: /phpmyadmindocument length: 337 bytes
concurrency level: 1time taken for tests: 20.699322 secondscomplete requests: 100000failed requests: 0write errors: 0non-2xx responses: 100000total transferred: 59100000 byteshtml transferred: 33700000 bytesrequests per second: 4831.08 [#/sec] (mean)time per request: 0.207 [ms] (mean)time per request: 0.207 [ms] (mean, across all concurrent requests)transfer rate: 2788.21 [kbytes/sec] received
connection times (ms)min mean[+/-sd] median maxconnect: 0 0 0.0 0 0processing: 0 0 1.2 0 294waiting: 0 0 1.2 0 294total: 0 0 1.2 0 294
percentage of the requests served within a certain time (ms)50% 066% 075% 080% 090% 095% 098% 099% 0100% 294 (longest request)主要的性能指标是requests per second,为了看着方便,只在第一次的给出所有反馈,其他的都之提供requests per second
结果:requests per second: 4831.08 [#/sec] (mean)
eaccelerator结果:requests per second: 4850.92 [#/sec] (mean)
eaccelerator 内存模式结果:requests per second: 4690.77 [#/sec] (mean)
xcache结果:requests per second: 4781.96 [#/sec] (mean)
发现eaccelerator与xcache可以同时安装,就也试验了一下。eaccelerator+xcache结果:requests per second: 4791.29 [#/sec] (mean)
测试的结果是eaccelerator 内存模式胜出。不过这样似乎看不出缓存器的必要,同时phpmyadmin也太单一了。下面开始对discuz!_6.0.0_sc_gbk的请求测试,这样对国内的用户才更加有参考意义。
discuz!部分说明:discuz!默认安装,不带任何的数据,discuz!自带了缓存功能不过默认没有开启,不影响测试的结果。
测试语句为:ab -n 100000 http://localhost/bbs/index.php针对discuz!测试又增加了一句:ab -n 100000 -c 200 http://localhost/bbs/index.php超bt^_^
ab -n 100000
不安装任何缓存器
[root@mandriva bbs]# ab -n 100000 http://localhost/bbs/index.phpthis is apachebench, version 2.0.40-dev apache-2.0copyright 1996 adam twiss, zeus technology ltd, http://www.zeustech.net/copyright 2006 the apache software foundation, http://www.apache.org/
benchmarking localhost (be patient)completed 10000 requestscompleted 20000 requestscompleted 30000 requestscompleted 40000 requestscompleted 50000 requestscompleted 60000 requestscompleted 70000 requestscompleted 80000 requestscompleted 90000 requestsfinished 100000 requests
server software: apache/2.2.6server hostname: localhostserver port: 80
document path: /bbs/index.phpdocument length: 9251 bytes
concurrency level: 1time taken for tests: 2278.10424 secondscomplete requests: 100000failed requests: 0write errors: 0total transferred: 958900000 byteshtml transferred: 925100000 bytesrequests per second: 43.90 [#/sec] (mean)time per request: 22.780 [ms] (mean)time per request: 22.780 [ms] (mean, across all concurrent requests)transfer rate: 411.07 [kbytes/sec] received
connection times (ms)min mean[+/-sd] median maxconnect: 0 0 0.0 0 0processing: 21 22 0.9 22 137waiting: 14 21 0.6 21 40total: 21 22 0.9 22 137
percentage of the requests served within a certain time (ms)50% 2266% 2275% 2280% 2390% 2395% 2398% 2499% 24100% 137 (longest request)
结果:requests per second: 43.90 [#/sec] (mean)
eaccelerator结果:requests per second: 167.28 [#/sec] (mean)
eaccelerator 内存模式结果:requests per second: 168.53 [#/sec] (mean)
xcache结果:requests per second: 191.68 [#/sec] (mean)
ab -n 100000 -c 200
不安装任何缓存器结果:requests per second: 77.73 [#/sec] (mean)
eaccelerator结果:requests per second: 317.69 [#/sec] (mean)
eaccelerator 内存模式结果:requests per second: 325.86 [#/sec] (mean)
xcache结果:requests per second: 388.76 [#/sec] (mean)
这时候结果已经很明显了xcache胜出,各项的差距也拉大了。
结果:xcache的性能相当的不错,可以取代eaccelerator。eaccelerator的内存模式对eaccelerator的性能提升不是很大,用了反而会增加系统配置的复杂度。
同时要注意的是mysql的性能,在进行discuz!部分测试的时候cpu占用率几乎是100%。在没有安装任何缓存器的时mysql的占用率只有10%左右,其他的都被apache占去。安装任何一款缓冲器时,单线程mysql的占用率35%左右,多线程的时候是40%左右,其他的都被apache占去。这样看来缓存器在php应用中是非常重要的,一个缓存器可以大大减轻apache的负担,所以建议所有的php用户都安装一个缓存器。
后记:这次的测试用的参数有点bt了^_^,不过我们就是想得到一个近似合理的测试结果,时间长一点也不过分。
其它类似信息

推荐信息