[轉貼]eAccelerator的安装和性能比较

網站架設,免費空間申請,架站技術交流區

ETERNAL
 
文章: 2937
註冊時間: 2003-12-03 11:08 pm
性別: 男生

[轉貼]eAccelerator的安装和性能比较

文章ETERNAL » 2008-05-27 10:27 am

官方網站
http://eaccelerator.net/

编译:需要有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启用了
This program makes use of the Zend Scripting Language Engine:
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
with eAccelerator v0.9.4, Copyright (c) 2004-2004 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


水色論壇 http://www.et99.net
簡恩峻分享


ETERNAL
 
文章: 2937
註冊時間: 2003-12-03 11:08 pm
性別: 男生

文章ETERNAL » 2008-05-27 2:09 pm

  [文章作者:张宴 本文版本:v1.1 最后修改:2007.03.02 转载请注明出处:http://blog.s135.com]

  操作系统:Linux
  
  一、安装eaccelerator-0.9.5(同时支持ZendOptimizer-3.2.2)
  
  1、首先安装ZendOptimizer-3.2.2
  
  # wget http://www.vista.ac.cn/linux/down/ZendO ... 386.tar.gz
  # tar zxvf ZendOptimizer-3.2.2-linux-glibc21-i386.tar.gz
  # cd ZendOptimizer-3.2.2-linux-glibc21-i386
  # ./install.sh
  
  在Please specify the location for installing ZendOptimizer:提示后输入ZendOptimizer安装路径,例如/data/webserver/zend
  在Confirm the location of your php.ini file:提示后输入php.ini文件所在目录,例如/data/webserver/php/etc
  在Specify the full path to the Apache control utility (apachectl):提示输入apachectl绝对路径,例如/data/webserver/apache/bin/apachectl
  
  
  2、再安装eaccelerator-0.9.5加速软件
  
  # wget http://www.vista.ac.cn/linux/down/eacce ... .5.tar.bz2
  # tar jxvf eaccelerator-0.9.5.tar.bz2
  # cd eaccelerator-0.9.5
  
  指定php所在路径:
  # export PHP_PREFIX="/data/webserver/php"
  # $PHP_PREFIX/bin/phpize
  # ./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
  # make
  # make install
  
  这时会将eaccelerator安装到php目录中,屏幕会显示eaccelerator.so所在路径,例如:
  Installing shared extensions: /data/webserver/php/lib/php/extensions/no-debug-zts-20060613/
  记住这个路径。
  
  eaccelerator即可以安装为PHP扩展,也可以安装为zend扩展,以下安装为PHP扩展。
  
  如果存在/etc/php.d目录,需要拷贝eaccelerator.ini到该目录下,然后修改缺省值。如果不存在,修改php.ini,在[zend]之前加入以下内容(注:必须放在[zend]之前):
  
  [eaccelerator]
  extension="/data/webserver/php/lib/php/extensions/no-debug-zts-20060613/eaccelerator.so"
  eaccelerator.shm_size="32"
  eaccelerator.cache_dir="/data/cache/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"
  
  建立缓存目录:
  # mkdir -p /data/cache/eaccelerator
  # chmod 0777 /data/cache/eaccelerator
  
  重启Apache:
  # service httpd restart
  
  
  3、检查ZendOptimizer和eaccelerator是否安装成功
  
  创建一个phpinfo.php文件,内容如下:
  <?php
   phpinfo();
  ?>
  
  将该文件放置到网站目录,在浏览器中访问,如果出现以下内容则安装成功:
  This program makes use of the Zend Scripting Language Engine:
  Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
   with eAccelerator v0.9.5, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
   with Zend Extension Manager v1.0.11, Copyright (c) 2003-2006, by Zend Technologies
   with Zend Optimizer v3.2.2, Copyright (c) 1998-2006, by Zend Technologies
  
  
  
  二、eaccelerator配置信息详解(根据官方英文说明翻译)
  
  extension="/data/webserver/php/lib/php/extensions/no-debug-zts-20060613/eaccelerator.so"
  
  解释:PHP扩展eaccelerator.so的路径。
  
  --------------------
  
  eaccelerator.shm_size="32"
  
  解释:eaccelerator可使用的共享内存大小(单位为MB)。
  
  在Linux下,单个进程的最大内存使用量受/proc/sys/kernel/shmmax中设置的数字限制(单位为字节),例如CentOS 4.4的shmmax默认值为33554432字节(33554432bytes/1024/1024=32MB)。
  
  临时更改该值:
  # echo 字节数 > /proc/sys/kernel/shmmax
  
  按照以上方法更改,在每次重启系统时,该值会被自动还原。如果想永久更改,可以修改/etc/sysctl.conf文件,设置:
  kernel.shmmax = 字节数
  
  --------------------
  
  eaccelerator.cache_dir="/data/cache/eaccelerator"
  
  解释:缓存路径,可以使用命令mkdir -p /data/cache/eaccelerator创建该目录,然后使用命令chmod 0777 /data/cache/eaccelerator设置该目录权限为0777
  
  --------------------
  
  eaccelerator.enable="1"
  
  解释:打开或者关闭eaccelerator。"1"指打开,"0"指关闭。默认值为"1"。
  
  --------------------
  
  eaccelerator.optimizer="1"
  
  解释:打开或者关闭代码优化,开启可以加快代码的执行速度。"1"指打开,"0"指关闭。默认值为"1"。
  
  --------------------
  
  eaccelerator.check_mtime="1"
  
  解释:当打开此项时,eaccelerator会在每次请求时检查php文件的修改时间,看其是否被修改过,这会耗费一点时间,如果php文件被修改过,eaccelerator会重新编译缓存该php文件。当关闭此项时,如果php文件被修改,则需要手工删除eaccelerator缓存,才能显示被修改的php文件。"1"指打开,"0"指关闭。默认值为"1"。
  
  --------------------
  
  eaccelerator.debug="0"
  
  解释:打开或者关闭调试记录。当打开时,eaccelerator会将对一个缓存文件的每次请求都写进log。打开此项只对调试eaccelerator是否有BUG时有益处。"1"指打开,"0"指关闭。默认值为"0"。
  
  --------------------
  
  eaccelerator.filter=""
  
  解释:决定哪些PHP文件应该被缓存。可以指定一个范围(比如"*.php *.phtml"),这样被指定的文件就会被缓存。如果该范围以!开头,被指定的文件就不会被缓存。默认值为"",表示缓存所有的PHP文件。
  
  --------------------
  
  eaccelerator.shm_max="0"
  
  解释:一个用户使用例如eaccelerator_put之类的函数能够往共享内存中加载的最大数据。默认值为"0",表示不限制。(单位为字节)
  
  --------------------
  
  eaccelerator.shm_ttl="0"
  
  解释:当没有足够的空闲共享内存去尝试缓冲一个新脚本时,将删除至少在shm_ttl秒之前没有被访问过的文件。默认值为"0",表示不尝试从共享内存中删除任何旧的脚本。(单位为秒)
  
  --------------------
  
  eaccelerator.shm_prune_period="0"
  
  解释:当没有足够的空闲共享内存去尝试缓冲一个新脚本时,将删所有旧脚本,前提是这个尝试在超过shm_prune_period秒之前被执行过。默认值为"0",表示不尝试从共享内存中删除任何旧的脚本。(单位为秒)
  
  --------------------
  
  eaccelerator.shm_only="0"
  
  解释:打开或者关闭在磁盘上缓存编译过的脚本。这个参数对会话数据和内容缓存没有效果。默认值为"0",表示使用磁盘和共享内存来缓存。
  
  --------------------
  
  eaccelerator.compress="1"
  
  解释:打开或者关闭缓存内容压缩。"1"指打开,"0"指关闭。默认值为"1"。
  
  --------------------
  
  eaccelerator.compress_level="9"
  
  解释:内存压缩的级别。默认值为"9",表示最大压缩。
  
  
  参考资料:
  1、Installing from source (http://www.eaccelerator.net/wiki/InstallFromSource)
  2、eAccelerator settings (http://www.eaccelerator.net/wiki/Settings)


水色論壇 http://www.et99.net
簡恩峻分享


回到 架站討論

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 7 位訪客