eAccelerator的安装和性能比较

简介: 上次尝试安装Wikipedia的镜像的时候,了解到了eAccelerator已经是很常用的PHP平台预编译加速的手段了。

上次尝试安装Wikipedia的镜像的时候,了解到了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启用了
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

 
目录
相关文章
|
7月前
|
存储 缓存 自然语言处理
深入PHP内核:理解OPcache的工作原理与优化实践
【5月更文挑战第6天】 在现代Web开发中,提升性能和响应速度是持续追求的目标。PHP作为一种广泛使用的服务端脚本语言,其执行效率至关重要。本文将深入探索PHP的OPcache(优化器缓存)组件,解析其如何改善PHP的性能表现。通过剖析OPcache的工作机制,我们将讨论有效的配置策略以及实践中的最佳优化方法,旨在帮助开发者充分理解并利用OPcache来提升应用性能。
|
缓存 监控 应用服务中间件
Nginx 为什么性能比较好?
Nginx 为什么性能比较好?
75 0
|
网络协议 应用服务中间件 Linux
Nginx 实现 10w+ 并发之 Linux 内核优化
由于默认的Linux内核参数考虑的是最通用场景,这明显不符合用于支持高并发访问的Web服务器的定义,所以需要修改Linux内核参数,是的Nginx可以拥有更高的性能;
|
前端开发 应用服务中间件 PHP
Apache与Nginx的优缺点、性能比较,到底选择哪个比较好?
Apache与Nginx的优缺点、性能比较,到底选择哪个比较好? 1、nginx相对于apache的优点:  轻量级,同样起web 服务,比apache占用更少的内存及资源 抗并发,nginx 处理请求是异步非阻塞的,而apache 则是阻塞型的,在高并发下nginx 能保持低资源低消耗高性能.
3162 0
|
缓存 PHP 数据安全/隐私保护