eAccelerator的安裝和效能比較

cnbird發表於2008-02-15

上次嘗試安裝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

 


相關文章