用eAccelerator加速php
eAccelerator作为一种开源的 PHP 加速方案,在一些网站上测试性能表现显著,虽然ZendPlatform也有这个功能,但是想想它双 CPU 授权的售价高达 1495 美元一年,我想不是每一个人都能买得起的。
下面是安装和测试的笔记。
1.获取最新源代码
proz http://internap.dl.sourceforge.net/sourceforge/eaccelerator/eaccelerator-0.9.4.tar.bz2
2. 解压
tar -vxjf eaccelerator-0.9.4.tar.bz2
3. 编译
$cd eaccelerator-0.9.4
$export PHP_PREFIX=”/usr”
$$PHP_PREFIX/bin/phpize (如果没有这个命令,请安装php-devel包)
$./configure –enable-eaccelerator=shared –with-php-config=/usr/bin/php-config
$make
$sudo make install
4.添加一个基于php的配置文件
#cd /etc/php.d
#cat eaccelerator.ini
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″
5.重启apache
#/etc/init.d/httpd reload
接下来是针对本机的测试。
首先测试加载了该加速器的值
ab -n 1000 -c 100 http://localhost/index.php
Server Software: Apache/2.0.52
Server Hostname: localhost
Server Port: 80
Document Path: /index.php
Document Length: 363 bytes
Concurrency Level: 100
Time taken for tests: 14.435464 seconds
Complete requests: 1000
Failed requests: 639
(Connect: 0, Length: 639, Exceptions: 0)
Write errors: 0
Total transferred: 17680035 bytes
HTML transferred: 17496751 bytes
Requests per second: 69.27 [#/sec] (mean)
Time per request: 1443.546 [ms] (mean)
Time per request: 14.435 [ms] (mean, across all concurrent requests)
Transfer rate: 1196.01 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 1.3 0 5
Processing: 5 1240 1149.6 1153 4947
Waiting: 5 1236 1149.5 1153 4946
Total: 5 1241 1149.9 1157 4951
Percentage of the requests served within a certain time (ms)
50% 1157
66% 1561
75% 1873
80% 2062
90% 3092
95% 3390
98% 3967
99% 4622
100% 4951 (longest request)
接下来测试没有加载加速器模块
ab -n 1000 -c 100 http://localhost/index.php
Server Software: Apache/2.0.52
Server Hostname: localhost
Server Port: 80
Document Path: /index.php
Document Length: 32292 bytes
Concurrency Level: 100
Time taken for tests: 65.151732 seconds
Complete requests: 1000
Failed requests: 774
(Connect: 0, Length: 774, Exceptions: 0)
Write errors: 0
Total transferred: 7829669 bytes
HTML transferred: 7640006 bytes
Requests per second: 15.35 [#/sec] (mean)
Time per request: 6515.173 [ms] (mean)
Time per request: 65.152 [ms] (mean, across all concurrent requests)
Transfer rate: 117.36 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 3.8 0 106
Processing: 82 2395 5871.8 430 37210
Waiting: 82 2388 5864.8 426 37210
Total: 82 2395 5873.1 430 37214
Percentage of the requests served within a certain time (ms)
50% 430
66% 551
75% 3743
80% 4115
90% 4520
95% 6922
98% 34149
99% 35917
100% 37214 (longest request)
我们看看Requests per second(rps)值,有加速器的值是 69.27,没有加速器的值是15.35,提升343.21%
提升了3倍的请求数,让我很欣慰了。接下来就需要测试在实际服务器上的性能了。
原创文章,转载请注明: 转载自Linux|系统管理|WEB开发
本文链接地址: 用eAccelerator加速php




近期评论