• eAccelerator的安装和性能比较
    时间:2009-03-25   作者:佚名   出处:互联网

    上次尝试安装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

    网友留言/评论

    我要留言/评论