设为首页 收藏本站
查看: 1188|回复: 0

[经验分享] PHP 常用加速器 APC,eAccelerator & XCache

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-8-25 07:47:18 | 显示全部楼层 |阅读模式
  PHP 加速器是一个为了提高 PHP 执行效率,从而缓存起 PHP 的操作码,这样 PHP 后面执行就不用解析转换了,可以直接调用 PHP 操作码,这样速度上就提高了不少。
  Apache 中使用 mod_php 的请求、响应执行流程:
1、Apache 接收请求
2、Apache 传递请求给 mod_php
3、mod_php 定位磁盘文件,并加载到内存中
4、mod_php 编译源代码成为 opcode 树
5、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/
  XCache:XCache 是一个开源的 opcode 缓存器/优化器, 这意味着他能够提高您服务器上的 PHP 性能. 他通过把编译 PHP 后的数据缓冲到共享内存从而避免重复的编译过程, 能够直接使用缓冲区已编译的代码从而提高速度. 通常能够提高您的页面生成速率 2 到5 倍, 降低服务器负载(截取自:http://baike.baidu.com/view/1999371.htm)
  链接地址:http://xcache.lighttpd.net/wiki/WikiStart.
  
  APC VS eAccelerator VS XCache
  速度比较
DSC0000.jpg
  图中可以看到: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.

  • Website: http://pecl.php.net/package/APC
  • PHP version: works with all PHP versions including PHP 5.2-5.4 (3.1.10 - beta release) (not PHP 5.0)
  • Latest stable version: 3.1.9 (released 2011-05-14)
  • Status: stable, actively maintained.
  • Download link: http://pecl.php.net/package/APC (source)
  • Download link for Windows: http://downloads.php.net/pierre/ (provides some of the PECL extensions, previously available on pecl4win)
  • Official installation help: http://php.net/apc.setup
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.

  • Website: http://xcache.lighttpd.net/
  • PHP version: full support for PHP 5.4
  • Latest stable version: 2.0.1 (Released on 2012-07-14)
  • Status: Actively maintained (different releases stable/unstable/devel)
  • Download link: http://xcache.lighttpd.net/pub/Releases/2.0.1/xcache-2.0.1.tar.gz
  • Official installation help: http://xcache.lighttpd.net/wiki/InstallFromSource
  目前 APC 和 XCache 都有积极的维护和更新版本,eAccelerator 已经接近死亡状态了。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-103744-1-1.html 上篇帖子: as3与php 上传多张图片demo 下篇帖子: PHP快速入门(1)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表