eaccelerator真的能加速你的php吗?

Posted: 2009年8月3日星期一
经常看到很多介绍安装php的文章中,提到安装一个eaccelerator加速php程序,我按照他们的需求安装了,确实能用了,可是经过我的压力测试,发现他确实没有实现那些文章所谓的加速功能,是我配置错了,还是具体哪有问题,下面介绍一下我的配置情况,对于php的安装,搜索引擎一搜索网上一大堆,我就不累赘了,现在说说我的安装和eaccelerator的过程
php安装软件及版本
nginx/0.8.7
php-5.2.8
eaccelerator-0.9.5.3
eaccelerator安装

/usr/local/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make
sudo make install

eaccelerator配置
分成两块,一块是采用eaccelerator加速的就在php.ini文件中加入如下内容

[eaccelerator]
extension_dir = "/usr/local/lib/php/extensions"
extension="/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
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"

添加cache目录

mkdir /tmp/eaccelerator_cache

另一块就是初始化安装不配置任何参数进行测试
eaccelerator加速测试
ab -c 200 -n 10000 http://www.test.com/phpinfo.php
测试结果

Server Software: nginx/0.8.7
Server Hostname: www.test.com
Server Port: 80

Document Path: /test.php
Document Length: 25 bytes

Concurrency Level: 200
Time taken for tests: 1.523543 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Non-2xx responses: 10000
Total transferred: 2160000 bytes
HTML transferred: 250000 bytes
Requests per second: 6563.65 [#/sec] (mean)
Time per request: 30.471 [ms] (mean)
Time per request: 0.152 [ms] (mean, across all concurrent requests)
Transfer rate: 1384.27 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 1.8 0 15
Processing: 4 22 7.9 24 67
Waiting: 1 18 9.7 20 66
Total: 6 23 7.4 24 67

Percentage of the requests served within a certain time (ms)
50% 24
66% 24
75% 24
80% 25
90% 31
95% 32
98% 41
99% 61
100% 67 (longest request)

不采用eaccelerator加速测试
ab -c 200 -n 10000 http://www.test.com/phpinfo.php
测试结果

Server Software: nginx/0.8.7
Server Hostname: www.test.com
Server Port: 80

Document Path: /test.php
Document Length: 25 bytes

Concurrency Level: 200
Time taken for tests: 1.373767 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Non-2xx responses: 10011
Total transferred: 2162376 bytes
HTML transferred: 250275 bytes
Requests per second: 7279.25 [#/sec] (mean)
Time per request: 27.475 [ms] (mean)
Time per request: 0.137 [ms] (mean, across all concurrent requests)
Transfer rate: 1536.65 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 2 3.0 2 21
Processing: 4 24 11.4 23 94
Waiting: 2 17 12.9 15 93
Total: 5 26 11.1 26 94

Percentage of the requests served within a certain time (ms)
50% 26
66% 29
75% 31
80% 31
90% 32
95% 34
98% 83
99% 92
100% 94 (longest request)


结果说明:
通过ab的测试,从结果来看(只需要看黑体部分的内容就OK了),Requests per second(每秒事务数),Time per request(平均事务响应时间),Time per request(每个请求实际运行时间的平均值),这3个值在不采用eaccelerator加速的情况下,性能更强
总结:
不知是我的配置和测试的问题?还是在新的php版本中eaccelerator确实出现兼容性问题?

1 评论:

  1. Unknown 2009年10月6日 09:22

    测试方式不正确,phpinfo都是实时读取信息的。所以缓存不了opcode