| Subcribe via RSS

OP Cache大比拼: APC vs eAccelerator vs xcache, eAccelerator胜出

八月 25th, 2008 | 5 Comments | Posted in PHP < by Johnny Woo >

APC 3.0.19 (Alternative PHP Cache)
配置

extension=apc.so
apc.enabled=1
apc.shm_segments=1
apc.shm_size=128
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.enable_cli=1

结果

7303 fetches, 50 max parallel, 1.67458e+07 bytes, in 300 seconds
2293 mean bytes/connection
24.3433 fetches/sec, 55819.3 bytes/sec
msecs/connect: 3.27583 mean, 2999.74 max, 0.184 min
msecs/first-response: 2043.52 mean, 7853.21 max, 325.513 min
HTTP response codes:
  code 200 -- 7303

eAccelerator 0.9.5.3
配置

[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"

结果

7568 fetches, 50 max parallel, 1.73534e+07 bytes, in 300.001 seconds
2293 mean bytes/connection
25.2266 fetches/sec, 57844.6 bytes/sec
msecs/connect: 0.39873 mean, 1.01 max, 0.173 min
msecs/first-response: 1972.44 mean, 5520.1 max, 635.565 min
HTTP response codes:
  code 200 -- 7568

XCache v1.2.2
配置

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 = On
[xcache.coverager]
xcache.coverager = Off
xcache.coveragedump_directory = ""

结果

4539 fetches, 50 max parallel, 1.04079e+07 bytes, in 300 seconds
2293 mean bytes/connection
15.13 fetches/sec, 34693.1 bytes/sec
msecs/connect: 0.405883 mean, 0.999 max, 0.182 min
msecs/first-response: 3214.64 mean, 18691.3 max, 772.952 min
HTTP response codes:
  code 200 -- 4539

No OP-Cache
结果

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

结论:
eAccelerator 0.9.5.3
25.2266 fetches/sec

APC 3.0.19
24.3433 fetches/sec

XCache v1.2.2
15.13 fetches/sec

No OP-Cache
5.99332 fetches/sec

eA的效果最好.APC紧随其后.两者的性能表现基本相同.xcache最差.

阅读内文 Tags: , , , , ,

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

八月 22nd, 2008 | 6 Comments | Posted in PHP < by Johnny Woo >

网上有一篇比较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:
所有的测试都会和参数调优有一定关系.
不是所有的测试都是准确的
测试始终会有局限性.
本例也不例外

阅读内文 Tags: , , ,