今天闲来无事,用自己的VPS作为测试平台,测试Xcache3.0和eAccelerator1.0哪个性能更好.第一次做这种事情,做得不够专业请指正,呵呵.
处理器:Intel(R) Xeon(R) CPU E31240 @ 3.30GHz × 2
内存:1GB
测试工具:使用Apache Benchmark作为压力测试工具,并发数10,请求数5000
软件:nginx1.2.6+apache2.2.23+mysql5.5.29+ZendEngine2.3.0+ZendGuardLoader3.3
测试网站:新建phpwind9.0论坛作为测试页面(为了避免被恶意攻击,测试结果隐藏了Hostname)
不使用eAccelerator1.0和Xcache3.0,测试结果:
Server Software: nginx/1.2.6
Server Hostname: ***.***.***
Server Port: 80
Document Path: /phpwind/
Document Length: 10903 bytes
Concurrency Level: 10
Time taken for tests: 283.546 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 57323498 bytes
HTML transferred: 54515000 bytes
Requests per second: 17.63 [#/sec] (mean)
Time per request: 567.091 [ms] (mean)
Time per request: 56.709 [ms] (mean, across all concurrent requests)
Transfer rate: 197.43 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 3
Processing: 308 567 31.1 564 699
Waiting: 300 517 29.1 515 642
Total: 308 567 31.1 564 699
Percentage of the requests served within a certain time (ms)
50% 564
66% 577
75% 585
80% 590
90% 607
95% 621
98% 638
99% 650
100% 699 (longest request)
只使用eAccelerator1.0,测试结果:
Server Software: nginx/1.2.6
Server Hostname: ***.***.***
Server Port: 80
Document Path: /phpwind/
Document Length: 10903 bytes
Concurrency Level: 10
Time taken for tests: 247.201 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 57323978 bytes
HTML transferred: 54515000 bytes
Requests per second: 20.23 [#/sec] (mean)
Time per request: 494.402 [ms] (mean)
Time per request: 49.440 [ms] (mean, across all concurrent requests)
Transfer rate: 226.46 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 4
Processing: 319 494 35.7 491 688
Waiting: 312 454 34.4 451 639
Total: 319 494 35.7 491 688
Percentage of the requests served within a certain time (ms)
50% 491
66% 505
75% 514
80% 520
90% 541
95% 559
98% 582
99% 598
100% 688 (longest request)
只使用Xcache3.0,测试结果:
Server Software: nginx/1.2.6
Server Hostname: ***.***.***
Server Port: 80
Document Path: /phpwind/
Document Length: 10903 bytes
Concurrency Level: 10
Time taken for tests: 1560.616 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 57323430 bytes
HTML transferred: 54515000 bytes
Requests per second: 3.20 [#/sec] (mean)
Time per request: 3121.232 [ms] (mean)
Time per request: 312.123 [ms] (mean, across all concurrent requests)
Transfer rate: 35.87 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 1702 3120 183.2 3098 4918
Waiting: 1657 2976 175.0 2956 4745
Total: 1702 3120 183.2 3098 4920
Percentage of the requests served within a certain time (ms)
50% 3098
66% 3166
75% 3212
80% 3249
90% 3361
95% 3453
98% 3578
99% 3634
100% 4920 (longest request)
结果总结
结果令我很惊讶!!不知道是我的XCache3.0设置问题还是怎么回事,XCache3.0很慢啊,比不用还要慢!?!?而且在测试期间CPU平均负载达到了10!?!?但愿是我设置问题。。。自己先琢磨一阵,如果找到哪里出问题了,再来更新。。。。
就目前结果分析,eAccelerator1.0对LNAMP的加速效果明显。在并发数为10的情况下处理5000个请求,如果不用eAccelerator1.0,则要花费283.546秒,使用了以后,花费的时间减少到了247.201秒,足足减少了近40秒。
本次测试并发连接数为10,请求数为5000,就能有40秒差距,相信如果并发连接数更多,总的连接数更多,eAccelerator1.0的加速效果会更明显。所以对大流量高并发连接的网站来说,加速效果绝对是很给力的!
而对于XCache3.0。。。。我暂时不做评论。。。。也许是XCache3.0和ZendGuard3.3冲突了,这里先保留测试结果,等我琢磨透了再做评论。。。。
事实证明,XCache3.0和ZendGuard3.3并没有冲突,我把ZendGuard3.3禁用了,结果XCache3.0还是那样。。。
对于这次XCache3.0测试结果这么奇怪,为此我把我使用的XCache3.0的设置贴上来,欢迎指正:
[XCache]
extension = "/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/xcache.so"
xcache.admin.auth = On
xcache.admin.user = "xcache"
xcache.admin.pass = "8e6867a5d05144cf4761d6481fc674a8"
xcache.size = 64M
xcache.shm_scheme = "mmap"
xcache.count = 4
xcache.slots = 8K
xcache.ttl = 0
xcache.gc_interval = 0
xcache.var_size = 16M
xcache.var_count = 4
xcache.var_slots = 8K
xcache.var_ttl = 0
xcache.var_maxttl = 0
xcache.var_gc_interval = 300
xcache.test = Off
xcache.readonly_protection = Off
xcache.mmap_path = "/dev/zero"
xcache.coredump_directory = ""
xcache.cacher = On
xcache.stat = On
xcache.optimizer = On