快捷搜索:   服务器  安全  linux 安全  MYSQL  dedecms

php缓存加速器:eaccelerator与xcache性能测试对比

随着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/phpmyadmin
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 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 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Finished 100000 requests

Server Software: Apache/2.2.6
Server Hostname: localhost
Server Port: 80

Document Path: /phpmyadmin
Document Length: 337 bytes

Concurrency Level: 1
Time taken for tests: 20.699322 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Non-2xx responses: 100000
Total transferred: 59100000 bytes
HTML transferred: 33700000 bytes
Requests 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 max
Connect: 0 0 0.0 0 0
Processing: 0 0 1.2 0 294
Waiting: 0 0 1.2 0 294
Total: 0 0 1.2 0 294

Percentage of the requests served within a certain time (ms)
50% 0
66% 0
75% 0
80% 0
90% 0
95% 0
98% 0
99% 0
100% 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.php
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 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 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Finished 100000 requests

顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论