PHP 經常使用加速器 APC,eAccelerator & XCache

PHP 加速器是一個爲了提升 PHP 執行效率,從而緩存起 PHP 的操做碼,這樣 PHP 後面執行就不用解析轉換了,能夠直接調用 PHP 操做碼,這樣速度上就提升了很多。php

Apache 中使用 mod_php 的請求、響應執行流程:
一、Apache 接收請求
二、Apache 傳遞請求給 mod_php
三、mod_php 定位磁盤文件,並加載到內存中
四、mod_php 編譯源代碼成爲 opcode 樹
五、mod_php 執行 opcode 樹緩存

PHP 加速器相應的就是第四步,它的目的就是防止 PHP 每次請求都重複編譯PHP代碼,由於在高訪問量的網站上,大量的編譯每每沒有執行速度快呢?因此這裏面有個瓶頸就是PHP的重複編譯既影響了速度又加載了服務器負載,爲了解決此問題,PHP加速器就這樣誕生了。 服務器

APC:Alternative PHP Cache(APC)是 PHP 的一個免費公開的優化代碼緩存。它用來提供免費,公開而且強健的架構來緩存和優化 PHP 的中間代碼。
連接地址:http://php.net/manual/en/book.apc.php架構

eAccelerator:eAccelerator 是一個自由開放源碼php加速器,優化和動態內容緩存,提升了 php 腳本的緩存性能,使得PHP腳本在編譯的狀態下,對服務器的開銷幾乎徹底消除。 它還有對腳本起優化做用,以加快其執行效率。使您的PHP程序代碼執效率能提升1-10倍(截取自:http://baike.baidu.com/view/1376127.htm
連接地址:http://eaccelerator.net/ide

XCache:XCache 是一個開源的 opcode 緩存器/優化器, 這意味着他可以提升您服務器上的 PHP 性能. 他經過把編譯 PHP 後的數據緩衝到共享內存從而避免重複的編譯過程, 可以直接使用緩衝區已編譯的代碼從而提升速度. 一般可以提升您的頁面生成速率 2 到5 倍, 下降服務器負載(截取自:http://baike.baidu.com/view/1999371.htm
連接地址:http://xcache.lighttpd.net/wiki/WikiStart.svn

APC VS eAccelerator VS XCache 性能

速度比較測試

圖中能夠看到:APC,XCache,eAccelerator 的測試數據,相對來講 XCache 表現最好,可是每一個加速器都有各類微調參數,具體視部署環境而定。優化

版本存活狀態網站

(截取自:http://en.wikipedia.org/wiki/List_of_PHP_accelerators

Alternative PHP Cache (APC)

Alternative PHP Cache is a free, open source (PHP license) framework that optimizes PHP intermediate code and caches data and compiled code from the PHP bytecode compiler in shared memory.

eAccelerator

eAccelerator was born in December 2004 as a fork of the Turck MMCache project. Turck MMCache was created by Dmitry Stogov and much of the eAccelerator code is still based on his work. eAccelerator also contained a PHP encoder and loader, but the development staff discontinued the encoder and removed this feature after December 2006.

  • Website: http://eaccelerator.net/
  • PHP version: Supports PHP 4 and all PHP 5 thread-safe releases including 5.3 from version 0.9.6; breaks on 5.4. In older releases, the encoder will only work with PHP versions from the 4.x.x branch. eAccelerator will not work with any other versions of PHP. eAccelerator can only be used with the thread-safe version of PHP. (This seems not to be true, this version works for my php non-thread-safe installation: http://eac.qme.nl/eAccelerator_v1_0_svn427_for_v5_3_X-VC9.zip)
  • Latest stable version: 0.9.6.1 (2010-05-31)
  • Status: Potentially dead (no new releases since May 2010). UPDATE from eaccelerator.net: 25 Jul 2012 - Project was taken by Hans Rakers and moved to Github, master branch does support PHP 5.4
  • Download link: (look for latest versions) http://eaccelerator.net/download page on SourceForge
  • Official installation help: https://eaccelerator.net/wiki/InstallFromSource

XCache

XCache is a fast, stable PHP opcode cacher that has been tested and is now running on production servers under high load. It is tested on Linux and FreeBSD and supported under Windows, for thread-safe and non-thread-safe versions of PHP. This relatively new opcode caching software has been developed by mOo, one of developers of Lighttpd, to overcome some of the limitations of the existing solutions at that time; such as being able to use it with new PHP versions as they arrive.

目前 APC 和 XCache 都有積極的維護和更新版本,eAccelerator 已經接近死亡狀態了。

相關文章
相關標籤/搜索