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/ideXCache: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 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 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.
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 已经接近死亡状态了。