- 论坛徽章:
- 0
|
1、下载安装
##官网:
http://www.eaccelerator.net
wget -c
http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2
tar xjf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make && make install
2、配置php.ini
vi /opt/modules/phpcgi/lib/php.ini
找到 cgi.fix_pathinfo 修改为 cgi.fix_pathinfo = 1
然后在下面加入
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.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"
然后将 extension_dir 修改为:
extension_dir = "/opt/modules/phpcgi/lib/php/extensions/no-debug-non-zts-20060613/"
mkdir /tmp/eaccelerator
chmod 777 /tmp/eaccelerator
3、检查是否成功加载eaccelerator
重起web服务,查看info.php是否显示:Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
或运行
[root@localhost lib]# /usr/local/php/bin/php -v
PHP 5.2.4 (cli) (built: Jun 18 2008 15:25:28)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
4、测试性能
测试情况 1 - 不使用 eAccelerator 时的情况
http://192.168.8.2/phpMyAdmin/index.php
动态页面测试结果
[root@localhost bin]# ./ab -n 100 -c 10 http://192.168.8.2/phpMyAdmin/index.php
This is ApacheBench, Version 2.0.40-dev apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.8.2 (be patient).....done
Server Software: Apache/2.2.6
Server Hostname: 192.168.8.2
Server Port: 80
Document Path: /phpMyAdmin/index.php
Document Length: 2473 bytes
Concurrency Level: 10
Time taken for tests: 8.665154 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 355386 bytes
HTML transferred: 247300 bytes
Requests per second: 11.54 [#/sec] (mean)
Time per request: 866.515 [ms] (mean)
Time per request: 86.652 [ms] (mean, across all concurrent requests)
Transfer rate: 40.05 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 22 77.5 0 336
Processing: 170 833 777.9 738 4877
Waiting: 170 830 780.4 738 4876
Total: 170 856 787.4 738 4877
Percentage of the requests served within a certain time (ms)
50% 738
66% 810
75% 932
80% 1004
90% 1259
95% 2776
98% 4051
99% 4877
100% 4877 (longest request)
[root@localhost bin]# ./ab -n 100 -c 10 http://192.168.8.2/phpMyAdmin/sql.php?db=oa&token=22ea2351885ebf84c09428ac7a2feb88&table=task&goto=tbl_structure.php
[1] 13345
[2] 13346
[3] 13347
This is ApacheBench, Version 2.0.40-dev apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.8.2 (be patient)...[root@localhost bin]# ..done
Server Software: Apache/2.2.6
Server Hostname: 192.168.8.2
Server Port: 80
Document Path: /phpMyAdmin/sql.php?db=oa
Document Length: 4115 bytes
Concurrency Level: 10
Time taken for tests: 10.932115 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 526160 bytes
HTML transferred: 411500 bytes
Requests per second: 9.15 [#/sec] (mean)
Time per request: 1093.211 [ms] (mean)
Time per request: 109.321 [ms] (mean, across all concurrent requests)
Transfer rate: 46.93 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 12 41.0 0 155
Processing: 106 1064 2653.5 108 10696
Waiting: 106 1062 2653.7 108 10695
Total: 106 1076 2664.9 108 10851
Percentage of the requests served within a certain time (ms)
50% 108
66% 109
75% 109
80% 589
90% 2877
95% 9528
98% 10816
99% 10851
100% 10851 (longest request)
[1] Done ./ab -n 100 -c 10 http://192.168.8.2/phpMyAdmin/sql.php?db=oa
[2]- Done token=22ea2351885ebf84c09428ac7a2feb88
[3]+ Done table=task
测试情况 2 - 使用 eAccelerator 时的情况
[root@localhost lib]# /usr/local/php/bin/php -v
PHP 5.2.4 (cli) (built: Jun 18 2008 15:25:28)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
[root@localhost lib]# cd /usr/local/apache2/bin/
[root@localhost bin]# ./ab -n 100 -c 10 http://192.168.8.2/phpMyAdmin/index.php
This is ApacheBench, Version 2.0.40-dev apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.8.2 (be patient).....done
Server Software: Apache/2.2.6
Server Hostname: 192.168.8.2
Server Port: 80
Document Path: /phpMyAdmin/index.php
Document Length: 2473 bytes
Concurrency Level: 10
Time taken for tests: 2.835400 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 355376 bytes
HTML transferred: 247300 bytes
Requests per second: 35.27 [#/sec] (mean)
Time per request: 283.540 [ms] (mean)
Time per request: 28.354 [ms] (mean, across all concurrent requests)
Transfer rate: 122.38 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 16 53.8 0 200
Processing: 75 260 248.1 177 1261
Waiting: 75 258 242.1 177 1141
Total: 75 277 256.6 178 1301
Percentage of the requests served within a certain time (ms)
50% 178
66% 231
75% 342
80% 382
90% 674
95% 895
98% 1261
99% 1301
100% 1301 (longest request)
[root@localhost bin]# ./ab -n 100 -c 10 http://192.168.8.2/phpMyAdmin/sql.php?db=oa&token=22ea2351885ebf84c09428ac7a2feb88&table=task&goto=tbl_structure.php
[1] 19266
[2] 19267
[3] 19268
[root@localhost bin]# This is ApacheBench, Version 2.0.40-dev apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.8.2 (be patient).....done
Server Software: Apache/2.2.6
Server Hostname: 192.168.8.2
Server Port: 80
Document Path: /phpMyAdmin/sql.php?db=oa
Document Length: 4115 bytes
Concurrency Level: 10
Time taken for tests: 3.46011 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 526186 bytes
HTML transferred: 411500 bytes
Requests per second: 32.83 [#/sec] (mean)
Time per request: 304.601 [ms] (mean)
Time per request: 30.460 [ms] (mean, across all concurrent requests)
Transfer rate: 168.42 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 2 6.5 0 23
Processing: 28 296 354.0 147 1516
Waiting: 28 296 354.2 147 1516
Total: 28 298 354.0 147 1516
Percentage of the requests served within a certain time (ms)
50% 147
66% 353
75% 387
80% 417
90% 704
95% 1433
98% 1473
99% 1516
100% 1516 (longest request)
[1] Done ./ab -n 100 -c 10 http://192.168.8.2/phpMyAdmin/sql.php?db=oa
[2]- Done token=22ea2351885ebf84c09428ac7a2feb88
[3]+ Done table=task
测试后发现eaccelerator将php执行速度提升了近2-3倍
参考文章:http://bbs.chinaunix.net/thread-1207750-1-1.html
http://bbs.chinaunix.net/viewthread.php?tid=525789&highlight=eAccelerator
[/url]
本文来自ChinaUnix博客,如果查看原文请点:[url]http://blog.chinaunix.net/u/17050/showart_1199081.html |
|