关闭

PHP 预编译加速: eAccelerator的安装和性能比较

标签: phpprocessingapacheconcurrencyextensionfile
2054人阅读 评论(0) 收藏 举报
分类:

eAccelerator已经是很常用的PHP平台预编译加速的手段了。今天在自己机器上尝试安装了一下,备忘如下:

获得源代码:
http://bart.eaccelerator.net/source/
编译:需要有autoconf支持,解包后在源程序目录下:

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


配置增加如下:sudo vi /usr/local/lib/php.ini

extension_dir = "/usr/local/lib/php/extensions"
extension="/no-debug-non-zts-20060613/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"

2006-06-03更新
在apache 2.2的升级过程中:发现php的相关模块都需要重新编译 需要注意包含哪个目录下的 eaccelerator.so 文件
/usr/local/lib/php/extensions$ ls -1
no-debug-non-zts-20020429
no-debug-zts-20020429
否则eAccelerator会无法生效, 我测试的结果在apache 2.2下eAccelerator的效果比apache 1.3下还差一些;

最好创建专用的缓存目录:

sudo mkdir /tmp/eaccelerator
sudo chmod 0777 /tmp/eaccelerator


重启一下apache:
sudo /home/apache/bin/apachectl restart
通过phpinfo()已经可以看到:eAccelerator启用了
[chedong@chedong eaccelerator-0.9.5.3]$ php -v
PHP 5.2.8 (cli) (built: Jan 14 2009 02:44:39)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator

用phpinfo这个脚本本身还做了一下性能对比测试:对于纯php代码(不考虑数据库瓶颈/文件IO等操作)的运行效率的确有3-5倍的效率提升;

测试:
/home/apache/bin/ab -c 20 -n1000 http://www.chedong.com/phpMan.php/phpinfo

eAccelerator 启用 |eAccelerator 关闭 Document Length: 32006 bytes |Document Length: 29136 bytes Concurrency Level: 20 |Concurrency Level: 20 Time taken for tests: 5.813 seconds |Time taken for tests: 23.896 seconds Complete requests: 1000 |Complete requests: 1000 Failed requests: 89 |Failed requests: 109 (Connect: 0, Length: 89, Exceptions: 0) | (Connect: 0, Length: 109, Exceptions: 0) Broken pipe errors: 0 |Broken pipe errors: 0 Total transferred: 32534962 bytes |Total transferred: 29578714 bytes HTML transferred: 32263316 bytes |HTML transferred: 29308693 bytes Requests per second: 172.03 [#/sec] (mean) |Requests per second: 41.85 [#/sec] (mean) Time per request: 116.26 [ms] (mean) |Time per request: 477.92 [ms] (mean) Time per request: 5.81 [ms] |Time per request: 23.90 [ms] Transfer rate: 5596.93 [Kbytes/sec] received |Transfer rate: 1237.81 [Kbytes/sec] received | Connnection Times (ms) |Connnection Times (ms) min mean[+/-sd] median max | min mean[+/-sd] median max Connect: 0 19 12.1 17 72 |Connect: 0 91 58.9 89 424 Processing: 53 92 22.0 90 219 |Processing: 140 379 209.6 366 4078 Waiting: 39 89 21.9 88 218 |Waiting: 113 359 210.6 349 4076 Total: 53 111 16.4 109 251 |Total: 140 470 203.7 450 4321 | Percentage of the requests served within a certain time (ms) |Percentage of the requests served within a certain time (ms) 50% 109 | 50% 450 66% 110 | 66% 453 75% 111 | 75% 456 80% 116 | 80% 460 90% 130 | 90% 490 95% 145 | 95% 626 98% 158 | 98% 830 99% 167 | 99% 831 100% 251 (last request) | 100% 4321 (last request)

2006-08-21
用yum安装autoconf时候出警告:

warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID db42a60e
Public key for autoconf-2.59-5.noarch.rpm is not installed
Retrieving GPG key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
GPG key at file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora (0x4F2A6FD2) is already installed

The GPG keys listed for the "Fedora Core 4 - i386 - Base" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.

按照Dan的回复:修复一下 rpm --import /usr/share/rhn/RPM-GPG-KEY 然后再安装就可以了。

2006-11-03 升级PHP后,eAccelerator需要重新编译,并且设置扩展的公共根路径:
; Directory in which the loadable extensions (modules) reside.
extension_dir = "/usr/local/lib/php/extensions"
extension="/no-debug-non-zts-20060613/eaccelerator.so"

否则会出现错误:

PHP Warning: Unknown(): Unable to load dynamic library './/usr/local/lib/php/extensions/no-debug-non-zts-20020429/eaccelerator.so' - .//usr/local/lib/php/extensions/no-debug-non-zts-20020429/eaccelerator.so: cannot open shared object file: No such file or directory in Unknown on line 0

作者:车东 发表于:2006-05-25 15:05 最后更新于:2009-01-14 12:01
版权声明:可以任意转载,转载时请务必以超链接形式标明文章和作者信息及本版权声明

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:10017271次
    • 积分:101224
    • 等级:
    • 排名:第10名
    • 原创:1539篇
    • 转载:141篇
    • 译文:9篇
    • 评论:4037条
    文章分类
    最新评论