IT流言终结者3:eaccelerator与xcache性能测试对比
网上有一篇比较eAccelerator与xcache的性能的文章 php缓冲器:eaccelerator与xcac...
扫描右侧二维码阅读全文
22
2008/08

IT流言终结者3:eaccelerator与xcache性能测试对比

网上有一篇比较eAccelerator与xcache的性能的文章
php缓冲器:eaccelerator与xcache性能测试对比
里面最终的结果是Xcache胜出
而这次由于生产环境调优的关系
我们同样适用Xcache与EA进行对比
选出能够提高生产环境效率的PHP OPCODE缓冲器
这次我们直接使用的是网站程序中的登录模块
整个网站基于SEAGULL 0.61框架.
前端是
APACHE 2.2.4
PHP 5.2.4
Xcache 1.1.2
eAccelerator 0.9.5.3
Zend Engine v2.2.0
测试工具http_load
参数

./http_load -p 50 -f 500 -s 300 phps

eAccelerator配置

extension="eaccelerator.so" eaccelerator.shm_size="16" eaccelerator.cache_dir="/tmp/eaccelerator" eaccelerator.enable="1" eaccelerator.optimizer="1" eaccelerator.check_mtime="1" eaccelerator.debug="0" eaccelerator.log_file = "/var/log/httpd/eaccelerator_log" eaccelerator.filter="" eaccelerator.shm_max="0" eaccelerator.shm_ttl="0" eaccelerator.shm_prune_period="0" eaccelerator.shm_only="0" eaccelerator.compress="1" eaccelerator.compress_level="9"

xcache配置

extension="xcache.so" [xcache.admin] ; Change xcache.admin.user to your preferred login name xcache.admin.user = "admin" ; Change xcache.admin.pass to the MD5 fingerprint of your password ; Use md5 -s "your_secret_password" to find the fingerprint xcache.admin.pass = "e10adc3949ba59abbe56e057f20f883e" [xcache] ; Change xcache.size to tune the size of the opcode cache xcache.size = 24M xcache.shm_scheme = "mmap" xcache.count = 2 xcache.slots = 8K xcache.ttl = 0 xcache.gc_interval = 0 ; Change xcache.var_size to adjust the size of variable cache xcache.var_size = 8M xcache.var_count = 1 xcache.var_slots = 8K xcache.var_ttl = 0 xcache.var_maxttl = 0 xcache.var_gc_interval = 300 xcache.test = Off xcache.readonly_protection = On xcache.mmap_path = "/tmp/xcache" xcache.coredump_directory = "" xcache.cacher = On xcache.stat = On xcache.optimizer = Off [xcache.coverager] xcache.coverager = On xcache.coveragedump_directory = ""

Zend配置

[Zend] zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.0 zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.0 zend_optimizer.version=3.3.0a zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so

测试结果(几次测试中取样代表性数据)

with nothing 1798 fetches, 50 max parallel, 3.9867e+06 bytes, in 300 seconds 2217.3 mean bytes/connection 5.99332 fetches/sec, 13289 bytes/sec msecs/connect: 12.0802 mean, 2999.48 max, 0.203 min msecs/first-response: 6966.64 mean, 59754 max, 381.002 min 41 timeouts 61 bad byte counts HTTP response codes: code 200 -- 1757 with eAccelerator v0.9.5.3 作为php扩展模块 7578 fetches, 50 max parallel, 1.73764e+07 bytes, in 300 seconds 2293 mean bytes/connection 25.26 fetches/sec, 57921.2 bytes/sec msecs/connect: 3.16951 mean, 3000.16 max, 0.141 min msecs/first-response: 1970.65 mean, 8268.16 max, 197.622 min HTTP response codes: code 200 -- 7578 with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator 作为zend扩展模块 7640 fetches, 50 max parallel, 1.75185e+07 bytes, in 300 seconds 2293 mean bytes/connection 25.4667 fetches/sec, 58395.1 bytes/sec msecs/connect: 3.14855 mean, 2999.92 max, 0.165 min msecs/first-response: 1954.57 mean, 8446.03 max, 267.841 min HTTP response codes: code 200 -- 7640 with eAccelerator v0.9.5.3 with Zend Extension Manager v1.2.2 with Zend Optimizer v3.3.0 作为php扩展模块 6732 fetches, 50 max parallel, 1.54365e+07 bytes, in 300 seconds 2293 mean bytes/connection 22.44 fetches/sec, 51454.9 bytes/sec msecs/connect: 0.40062 mean, 0.761 max, 0.177 min msecs/first-response: 2218.16 mean, 7707.3 max, 632.3 min HTTP response codes: code 200 -- 6732 with XCache v1.2.2 作为php扩展模块 4371 fetches, 50 max parallel, 9.96732e+06 bytes, in 300.001 seconds 2280.33 mean bytes/connection 14.57 fetches/sec, 33224.4 bytes/sec msecs/connect: 0.402745 mean, 0.763 max, 0.196 min msecs/first-response: 3355.27 mean, 54504.3 max, 576.103 min 2 timeouts 25 bad byte counts HTTP response codes: code 200 -- 4369 with XCache v1.2.2 作为php扩展模块 打开xcache.optimizer = On 4871 fetches, 50 max parallel, 1.11603e+07 bytes, in 300.001 seconds 2291.17 mean bytes/connection 16.2366 fetches/sec, 37200.9 bytes/sec msecs/connect: 4.71709 mean, 3000.64 max, 0.152 min msecs/first-response: 3047.7 mean, 27066.9 max, 557.86 min 4 bad byte counts HTTP response codes: code 200 -- 4871 with Zend Extension Manager v1.2.2 with XCache v1.2.2 作为zend扩展模块 1583 fetches, 50 max parallel, 3.5877e+06 bytes, in 300 seconds 2266.39 mean bytes/connection 5.27667 fetches/sec, 11959 bytes/sec msecs/connect: 0.39951 mean, 0.756 max, 0.163 min msecs/first-response: 9297.83 mean, 59294.4 max, 502.852 min 19 bad byte counts HTTP response codes: code 200 -- 1583

结果显示eAccelerator无论在速度还是稳定性上都大大超过xcache
而且在稳定性上大大提高.使用eA基本上没有出现过bad byte counts
而令人奇怪的就是Zend Optimizer加上eA后反而性能下降
xcache使用zend扩展模式
基本等于没有发挥任何作用.
此次测试没有Optimizer与Xcache的组合
是由于两者相互冲突.一旦加上Optimizer
不论是将xcache作为zend扩展还是php扩展
都会产生问题导致PHP无法执行.
所以最优的环境是只安装eA,如果你的PHP代码是经过加密的
很可惜,可能没有只使用EA性能这么好,不过下降的也不多.
但是比加了Optimizer就无法加载的XCACHE要好

国外有人也测试了一下eAccelerator和APC
结果EA的内存占用以及加速效果都好过APC
Benchmarking APC vs. eAccelerator using Drupal
另外一篇讲述OP-CACHE的文章
PHP op-code caches / accelerators: Drupal large site case study

我们的wordpress博客

with XCache v1.2.2 作为zend模块加载 329 fetches, 50 max parallel, 5.72335e+07 bytes, in 100 seconds 173962 mean bytes/connection 3.29 fetches/sec, 572334 bytes/sec msecs/connect: 1.09919 mean, 20.231 max, 0.184 min msecs/first-response: 13970.3 mean, 23204.4 max, 2489.5 min HTTP response codes: code 200 -- 329 with eAccelerator v0.9.5.3 作为php扩展模块 366 fetches, 50 max parallel, 6.36701e+07 bytes, in 100.001 seconds 173962 mean bytes/connection 3.65997 fetches/sec, 636696 bytes/sec msecs/connect: 0.47335 mean, 4.758 max, 0.21 min msecs/first-response: 12670.6 mean, 23359.5 max, 1469.66 min HTTP response codes

PS:
所有的测试都会和参数调优有一定关系.
不是所有的测试都是准确的
测试始终会有局限性.
本例也不例外

Last modification:November 26th, 2018 at 04:16 pm
If you think my article is useful to you, please feel free to appreciate

7 comments

  1. 福州seo

    以前一直用ea 不知道XC如何

  2. Michael Field

    被你测试下来xcache性能最差啊~

  3. GGclub

    我加了xcache之后,比不加前还要慢,郁闷的要死

  4. Johnny Woo

    是有这种情况发生.反而降低5~20%的性能
    可能和参数配置有关
    看看是否
    xcache.cacher = On

  5. Martian Guo

    xcache 确实不是想想当中那么好

  6. shunz

    xcache应该在zend Optimizer之前加载,否则会冲突

  7. georgexsh

    xcache应该加载为zend_ext并在zo之前加载,是可以和zo一起工作的
    另外我这边的性能还是xcache要好

Leave a Comment