设为首页 收藏本站
查看: 715|回复: 0

[经验分享] php缓冲器:eaccelerator与xcache性能测试对比

[复制链接]

尚未签到

发表于 2017-4-8 13:36:30 | 显示全部楼层 |阅读模式
  转载自:
  随着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
  不安装任何缓存器
  [iyunv@mandriva phpmyadmin]# ab -n 100000 http://localhost/phpmyadminThis is  ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $>  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
  不安装任何缓存器
  [iyunv@mandriva bbs]# ab -n 100000 http://localhost/bbs/index.phpThis  is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $>  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了^_^,不过我们就是想得到一个近似合理的测试结果,时间长一点也不过分。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-362031-1-1.html 上篇帖子: PHP类继承实例: 高中学生 -- 学生--人 下篇帖子: php 服务器跳转代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表