[Benchmark] eAccelerator v.s. APC on PHP 5.3

FreeBSD ports tree 的 lang/php5 升級到 5.3.2, www/eaccelerator 也升級到 0.9.6。
但是… 目前,FreeBSD ports tree 的 www/pecl-APC 依然是 3.0.19,無法在 PHP 5.3 運作;為了讓它正常運作,jnlin 送過 PR(我沒有先查詢,也送了一個 (羞) )。

其實 eAccelerator 0.9.6 在 2010 年 2 月初就已經釋出了,可是,從 changelog 看來,很多不錯的功能被砍掉(反璞歸真?):

Changes in this version:

* Support for PHP 5.3.
* The encoder is removed
* The user cache functions are removed
* The session handler is removed
* The minimal PHP version supported is now 5.1
* Some internal refactoring to clean up the code
* Fixed some bugs (and probably added some)

這麼看來,2008 年的這篇文章的參考價值就低了些…
為了滿足我自己的好奇心,就把 APC 3.1.3p1 裝起來測試看看。

系統/硬體:

  • CPU: Intel(R) Pentium(R) 4 CPU 3.00GHz
  • Memory: 6G(DDR2 800 MHz, Dual-Channel)
  • FreeBSD 8.0-RELEASE-p2 amd64
  • Apache HTTPD 2.2.14
  • PHP 5.3.2

設定:

  • eAccelerator 0.9.6:
    eaccelerator.shm_size="128"
    eaccelerator.cache_dir="/tmp/eaccelerator"
    eaccelerator.enable="1"
    eaccelerator.optimizer="1"
    eaccelerator.debug="0"
    eaccelerator.log_file="/var/log/eaccelerator.log"
    eaccelerator.name_space = ""
    eaccelerator.check_mtime="1"
    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"
    eaccelerator.keys="shm_and_disk"
  • APC 3.1.3p1:
    apc.enabled=1
    apc.shm_segments=1
    apc.shm_size=128
    apc.ttl=7200
    apc.user_ttl=7200
    apc.num_files_hint=1024
    apc.mmap_file_mask=/tmp/apc.cache
    apc.enable_cli=1

測試結果(ab -c5 -n500):

Pure PHPeAcceleratorAPC
WordPress 2.9.23.00 req./sec.
332.834 ms/req.
7.61 req./sec.
131.487 ms/req.
8.87 req./sec.
112.750 ms/req.
MediaWiki 1.15.31.81 req./sec.
552.822 ms/req.
2.75 req./sec.
363.124 ms/req.
5.93 req./sec.
168.580 ms/req.
Gallery 2.3.13.51 req./sec.
284.979 ms/req.
7.91 req./sec.
126.421 ms/req.
7.38 req./sec.
135.506 ms/req.

依照結果看來,APC 3.1.3p1 的確略勝 eAccelerator 0.9.6。 8-)
可惜的是.. Xcache 目前的最新版本(1.3.0)沒辦法在 PHP 5.3 跑…