<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>VPS侦探 &#187; 比较</title>
	<atom:link href="http://www.vpser.net/tag/%e6%af%94%e8%be%83/feed" rel="self" type="application/rss+xml" />
	<link>http://www.vpser.net</link>
	<description>致力于VPS主机推荐、VPS管理维护、VPS优惠信息及VPS相关的信息共享平台</description>
	<lastBuildDate>Mon, 06 Feb 2012 01:24:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>三款免费的PHP加速器：APC、eAccelerator、XCache比较</title>
		<link>http://www.vpser.net/opt/apc-eaccelerator-xcache.html</link>
		<comments>http://www.vpser.net/opt/apc-eaccelerator-xcache.html#comments</comments>
		<pubDate>Mon, 27 Jul 2009 04:00:30 +0000</pubDate>
		<dc:creator>VPSer</dc:creator>
				<category><![CDATA[VPS优化]]></category>
		<category><![CDATA[APC]]></category>
		<category><![CDATA[eAccelerator]]></category>
		<category><![CDATA[PHP加速器]]></category>
		<category><![CDATA[XCache]]></category>
		<category><![CDATA[免费]]></category>
		<category><![CDATA[比较]]></category>

		<guid isPermaLink="false">http://www.vpser.net/?p=409</guid>
		<description><![CDATA[一直想找一些关于PHP加速的文章，偶然看到杀客的这篇文章，感觉不错，分享给大家，再此感谢杀客。 一、PHP加速器介绍         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加速器就这样诞生了。 二、PHP加速器安装与配置         1、安装配置APC              APC全称是Alternative PHP Cache,官方翻译叫”可选PHP缓存”,它是PHP PECL中的一个扩展，好像是facebook在使用它，下面开始安装（ubuntu环境）：  $wget http://pecl.php.net/get/APC-3.0.19.tgz $tar xvzf APC-3.0.19.tgz $cd APC-3.0.19/APC-3.0.19 $/usr/local/php/bin/phpize $./configure –enable-apc –enable-apc-mmap –with-php-config=/usr/local/php/bin/php-config $make $sudo make install 下面我们再配置APC,因为我的PECL扩展路径改变了，所以我得移动下编译好的文件： $sudo mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/apc.so /usr/local/php/lib/php/extensions/PECL 然后我们再编辑php.ini文件进行配置，请把下面的代码加入到php.ini中即可： extension_dir = "/usr/local/php/lib/php/extensions/PECL" extension = apc.so ; APC apc.enabled = 1 apc.shm_segments [...]]]></description>
			<content:encoded><![CDATA[<p>一直想找一些关于PHP加速的文章，偶然看到<a href="http://killker.com/blog/" target="_blank">杀客</a>的这篇文章，感觉不错，分享给大家，再此感谢杀客。</p>
<p><span style="font-size: medium;"><strong>一、PHP加速器介绍</strong></span></p>
<p>        PHP加速器是一个为了提高PHP执行效率，从而缓存起PHP的操作码，这样PHP后面执行就不用解析转换了，可以直接调用PHP操作码，这样速度上就提高了不少。</p>
<p>        Apache中使用mod_php的请求、响应执行流程：</p>
<p>　　1、Apache接收请求。<br />
2、Apache传递请求给mod_php。<br />
3、mod_php定位磁盘文件，并加载到内存中。<br />
4、mod_php编译源代码成为opcode树。<br />
5、mod_php执行opcode树。</p>
<p>       PHP加速器相应的就是第四步，它的目的就是防止PHP每次请求都重复编译PHP代码，因为在高访问量的网站上，大量的编译往往没有执行速度快呢？所以这里面有个瓶颈就是PHP的重复编译既影响了速度又加载了服务器负载，为了解决此问题，PHP加速器就这样诞生了。<span id="more-409"></span></p>
<p><strong><span style="font-size: medium;">二、PHP加速器安装与配置</span></strong></p>
<p>        <strong>1、安装配置APC</strong></p>
<p style="padding-left: 30px;">             APC全称是Alternative PHP Cache,官方翻译叫”可选PHP缓存”,它是PHP PECL中的一个扩展，好像是facebook在使用它，下面开始安装（ubuntu环境）： <br />
$wget http://pecl.php.net/get/APC-3.0.19.tgz<br />
$tar xvzf APC-3.0.19.tgz<br />
$cd APC-3.0.19/APC-3.0.19<br />
$/usr/local/php/bin/phpize<br />
$./configure –enable-apc –enable-apc-mmap –with-php-config=/usr/local/php/bin/php-config<br />
$make<br />
$sudo make install</p>
<p>下面我们再配置APC,因为我的PECL扩展路径改变了，所以我得移动下编译好的文件：<br />
$sudo mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/apc.so /usr/local/php/lib/php/extensions/PECL</p>
<p style="padding-left: 30px;">然后我们再编辑php.ini文件进行配置，请把下面的代码加入到php.ini中即可：<br />
extension_dir = "/usr/local/php/lib/php/extensions/PECL"<br />
extension = apc.so<br />
; APC<br />
apc.enabled = 1<br />
apc.shm_segments = 1<br />
apc.shm_size = 64<br />
apc.optimization = 1<br />
apc.num_files_hint = 0<br />
apc.ttl = 0<br />
apc.gc_ttl = 3600<br />
apc.cache_by_default = on</p>
<p>     这样重启apache就会在phpinfo()信息中显示。</p>
<p><strong>       2、安装配置eAccelerator</strong></p>
<p style="padding-left: 30px;">          eAccelerator的前身其实是truck-mmcache，因为开发truk-mmcache的人被Zend给招安了，所以开发eAccelerator的人继承了truk-mmcache的一些特性，设计出eAccelerator加速器。安装如下：<br />
$wget http://jaist.dl.sourceforge.net/sourceforge/eaccelerator/eaccelerator-0.9.5.tar.bz2<br />
$tar -jxf eaccelerator-0.9.5.tar.bz2<br />
$cd eaccelerator-0.9.5<br />
$/usr/local/php/bin/phpize<br />
$./configure –enable-eaccelerator=shared –with-php-config=/usr/local/php/bin/php-config<br />
$make<br />
$sudo make install<br />
$sudo mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so /usr/local/php/lib/php/extensions/PECL</p>
<p>将下面代码加入php.ini文件中<br />
extension = eaccelerator.so<br />
; eAccelerator<br />
eaccelerator.shm_size = "16"<br />
eaccelerator.cache_dir = "/tmp/eaccelerator"<br />
eaccelerator.enable = "1"<br />
eaccelerator.optimizer = "1"<br />
eaccelerator.check_mtime = "1"<br />
eaccelerator.debug = "0"<br />
eaccelerator.filter = ""<br />
eaccelerator.shm_max = "0"<br />
eaccelerator.shm_ttl = "0"<br />
eaccelerator.prune_period = "0"<br />
eaccelerator.shm_only = "0"<br />
eaccelerator.compress = "1"<br />
eaccelerator.compress_level = "9"</p>
<p>创建缓存目录,重启apache</p>
<p>$sudo mkdir /tmp/eaccelerator<br />
$sudo chmod 777 /tmp/eaccelerator<br />
$sudo /usr/local/apache/apachectl restart</p>
<p>在phpinfo()检查是否安装成功.</p>
<p>3、安装配置XCache</p>
<p>XCache作为国人自己开发的东西，做小菜鸟的我也感到骄傲，而且XCache无论在速度还是性能上都做的不错。下面就赶紧让我们品尝它吧！</p>
<p>$wget http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz<br />
$tar xvzf xcache-1.2.2.tar.gz<br />
$cd xcache-1.2.2<br />
$/usr/local/php/bin/phpize<br />
$./configure –enable-xcache –enable-xcache-coverager –with-php-config=/usr/local/php/php-config<br />
$make<br />
$sudo make install<br />
$sudo mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/xcache.so /usr/local/php/lib/php/extensions/PECL</p>
<p>在php.ini添加配置信息：</p>
<p>extension = xcache.so<br />
; xcache<br />
xcache.admin.user = "admin"<br />
xcache.admin.pass = "(执行) echo ’(你的密码)’|md5sum(得出的密文)"<br />
;<br />
xcache.size = 24M<br />
xcache.shm_scheme = "mmap"<br />
xcache.count = 2<br />
xcache.slots = 8k<br />
xcache.ttl = 0<br />
xcache.gc_interval = 0</p>
<p>xcache.var_size = 8M<br />
xcache.var_count = 1<br />
xcache.var_slots = 8k<br />
xcache.var_ttl = 0<br />
xcache.var_maxttl = 0<br />
xcache.var_gc_interval = 300<br />
xcache.test = Off<br />
xcache.readonly_protection = On<br />
xcache.mmap_path = "/tmp/xcache"<br />
xcache.coredump_directory = ""<br />
xcache.cacher = On<br />
xcache.stat = On<br />
xcache.optimizer = Off<br />
;<br />
xcache.coverager = On<br />
xcache.coveragedump_directory = ""</p>
<p>创建缓存目录，重启apache</p>
<p>$sudo mkdir /tmp/xcache<br />
$sudo chmod 777 /tmp/xcache<br />
$sudo /usr/local/apache/bin/apachectl restart</p>
<p>去查看phpinfo()信息吧！</p>
<p>三、PHP加速器测试</p>
<p>1、测试环境</p>
<p>硬件: AMD Athlon 64 X2 Dual Core Processor 4400+ @ 2.2GHz CPU, 2GB 内存. 160GB SATA 硬盘</p>
<p>软件: Linux Ubuntu server Gutsy 7.10, Apache 2.2.4, MySQL 5.0.45 和 PHP 5.2.3</p>
<p>测试指令: ab -c5 -n3000 http://example.com/ (我们使用的是Apache Benchmark (ab) 工具，并发连接为5，3000次请求)</p>
<p>2、测试结果</p>
<p>无任何加速器:</p>
<p>Document Path: /<br />
Document Length: 21757 bytes<br />
Concurrency Level: 5<br />
Time taken for tests: 288.255212 seconds<br />
Complete requests: 3000<br />
Failed requests: 0<br />
Write errors: 0<br />
Total transferred: 66777000 bytes<br />
HTML transferred: 65271000 bytes<br />
Requests per second: 10.41 [#/sec] (mean)<br />
Time per request: 480.425 [ms] (mean)<br />
Time per request: 96.085 [ms] (mean, across all concurrent requests)<br />
Transfer rate: 226.23 [Kbytes/sec] received<br />
Connection Times (ms)<br />
min mean[+/-sd] median max<br />
Connect: 0 0 0.5 0 19<br />
Processing: 181 479 186.0 444 1822<br />
Waiting: 166 461 184.7 427 1708<br />
Total: 181 479 186.0 444 1822<br />
Percentage of the requests served within a certain time (ms)<br />
50% 444<br />
66% 525<br />
75% 577<br />
80% 619<br />
90% 732<br />
95% 819<br />
98% 946<br />
99% 1012<br />
100% 1822 (longest request)</p>
<p>APC加速器:</p>
<p>Document Path: /<br />
Document Length: 21757 bytes<br />
Concurrency Level: 5<br />
Time taken for tests: 98.530068 seconds<br />
Complete requests: 3000<br />
Failed requests: 0<br />
Write errors: 0<br />
Total transferred: 66777000 bytes<br />
HTML transferred: 65271000 bytes<br />
Requests per second: 30.45 [#/sec] (mean)<br />
Time per request: 164.217 [ms] (mean)<br />
Time per request: 32.843 [ms] (mean, across all concurrent requests)<br />
Transfer rate: 661.84 [Kbytes/sec] received<br />
Connection Times (ms)<br />
min mean[+/-sd] median max<br />
Connect: 0 0 0.0 0 2<br />
Processing: 58 163 71.2 155 2452<br />
Waiting: 53 158 69.6 150 2329<br />
Total: 58 163 71.2 155 2452<br />
Percentage of the requests served within a certain time (ms)<br />
50% 155<br />
66% 178<br />
75% 193<br />
80% 204<br />
90% 235<br />
95% 258<br />
98% 285<br />
99% 302<br />
100% 2452 (longest request)</p>
<p>eAccelerator加速器:</p>
<p>Document Path: /<br />
Document Length: 21757 bytes<br />
Concurrency Level: 5<br />
Time taken for tests: 95.983986 seconds<br />
Complete requests: 3000<br />
Failed requests: 0<br />
Write errors: 0<br />
Total transferred: 66777000 bytes<br />
HTML transferred: 65271000 bytes<br />
Requests per second: 31.26 [#/sec] (mean)<br />
Time per request: 159.973 [ms] (mean)<br />
Time per request: 31.995 [ms] (mean, across all concurrent requests)<br />
Transfer rate: 679.39 [Kbytes/sec] received<br />
Connection Times (ms)<br />
min mean[+/-sd] median max<br />
Connect: 0 0 0.1 0 3<br />
Processing: 57 159 91.3 148 3830<br />
Waiting: 50 152 89.8 142 3704<br />
Total: 57 159 91.3 148 3830<br />
Percentage of the requests served within a certain time (ms)<br />
50% 148<br />
66% 174<br />
75% 193<br />
80% 205<br />
90% 239<br />
95% 263<br />
98% 289<br />
99% 309<br />
100% 3830 (longest request)</p>
<p>XCache加速器:</p>
<p>Document Path: /<br />
Document Length: 21757 bytes<br />
Concurrency Level: 5<br />
Time taken for tests: 99.76300 seconds<br />
Complete requests: 3000<br />
Failed requests: 0<br />
Write errors: 0<br />
Total transferred: 66777000 bytes<br />
HTML transferred: 65271000 bytes<br />
Requests per second: 30.28 [#/sec] (mean)<br />
Time per request: 165.127 [ms] (mean)<br />
Time per request: 33.025 [ms] (mean, across all concurrent requests)<br />
Transfer rate: 658.19 [Kbytes/sec] received<br />
Connection Times (ms)<br />
min mean[+/-sd] median max<br />
Connect: 0 0 0.0 0 2<br />
Processing: 59 164 83.4 155 3367<br />
Waiting: 52 156 66.4 148 1802<br />
Total: 59 164 83.4 155 3367<br />
Percentage of the requests served within a certain time (ms)<br />
50% 155<br />
66% 178<br />
75% 196<br />
80% 206<br />
90% 237<br />
95% 263<br />
98% 287<br />
99% 305<br />
100% 3367 (longest request)</p>
<p>3、结果摘要</p>
<table style="width: 562px; height: 98px;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td> </td>
<td>请求时间(秒)</td>
<td>单次请求时间(毫秒)</td>
<td>最大内存占用(MB)</td>
<td>最小内存占用(MB)</td>
</tr>
<tr>
<td>None</td>
<td>10.41</td>
<td>96.08</td>
<td>24</td>
<td>24</td>
</tr>
<tr>
<td><span style="COLOR: #0000ff">APC</span></td>
<td>30.45</td>
<td>32.84</td>
<td>21</td>
<td>21</td>
</tr>
<tr>
<td><span style="COLOR: #00ff00">eAccelerator</span></td>
<td>31.26</td>
<td>31.99</td>
<td>23</td>
<td>18</td>
</tr>
<tr>
<td><span style="COLOR: #ff0000">XCache</span></td>
<td>30.28</td>
<td>33.02</td>
<td>29</td>
<td>19</td>
</tr>
</tbody>
</table>
<p><span style="FONT-SIZE: medium"><strong>四、PHP加速器比较结果总结</strong></span></p>
<p>     1、通过测试得出eAccelerator在请求时间和内存占用综合方面是最好的。</p>
<p>     2、通过测试得出使用加速器比无加速器在请求时间快了3倍左右。</p>
<p>     3、通过各个官方观察，XCache是更新最快的，这也说明最有发展的。</p>
<p>        以上是总结结果，你也许会问我到底用那个加速器好呢？我只能告诉你，首先，用一定比不用好，其次每个加速器还有一些可以调优的参数，所以要根据你的系统环境而定，然后，我个人觉得你可以详细研究下eAccelerator和XCache，这两款潜力还是很大的，最后我从比较专业的测试网站搞了一张结果图：</p>
<p><a href="http://www.vpser.net/uploads/2009/07/cache.jpg" target="_blank"><img class="alignnone size-medium wp-image-420" title="cache" src="http://www.vpser.net/uploads/2009/07/cache-300x205.jpg" alt="cache" width="300" height="205" /></a></p>
<p>本文转载自：<a href="http://killker.com/blog/?p=94">http://killker.com/blog/?p=94</a></p>
<h2  class="related_post_title">相关文章：</h2><ul class="related_post"><li><a href="http://www.vpser.net/coupons/burst-net-vps-miami-florida-first-month-free-offer.html" title="Burst.net 美国佛罗里达迈阿密机房VPS首月免费">Burst.net 美国佛罗里达迈阿密机房VPS首月免费</a></li><li><a href="http://www.vpser.net/other/2th-anniversary-of-vpser.html" title="VPS侦探2周年 多个VPS服务商优惠码+免费赠送8个VPS1个月使用期大放送">VPS侦探2周年 多个VPS服务商优惠码+免费赠送8个VPS1个月使用期大放送</a></li><li><a href="http://www.vpser.net/coupons/photonvps-free-directadmin.html" title="PhotonVPS 免费DirectAdmin，限时抢购">PhotonVPS 免费DirectAdmin，限时抢购</a></li><li><a href="http://www.vpser.net/coupons/ecvps-free-directadmin.html" title="EcVPS 免费送Directadmin面板">EcVPS 免费送Directadmin面板</a></li><li><a href="http://www.vpser.net/manage/jiankongbao.html" title="监控宝 &#8211; VPS/服务器24小时免费监控">监控宝 &#8211; VPS/服务器24小时免费监控</a></li></ul><hr />
<p><small>© VPSer for <a href="http://www.vpser.net">VPS侦探</a>, 2009. |
<a href="http://www.vpser.net/opt/apc-eaccelerator-xcache.html">Permalink</a> |
<a href="http://www.vpser.net/opt/apc-eaccelerator-xcache.html#comments">14 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.vpser.net/opt/apc-eaccelerator-xcache.html&title=三款免费的PHP加速器：APC、eAccelerator、XCache比较">del.icio.us</a>
<br/>
Post tags: <a href="http://www.vpser.net/tag/apc" rel="tag">APC</a>, <a href="http://www.vpser.net/tag/eaccelerator" rel="tag">eAccelerator</a>, <a href="http://www.vpser.net/tag/php%e5%8a%a0%e9%80%9f%e5%99%a8" rel="tag">PHP加速器</a>, <a href="http://www.vpser.net/tag/xcache" rel="tag">XCache</a>, <a href="http://www.vpser.net/tag/%e5%85%8d%e8%b4%b9" rel="tag">免费</a>, <a href="http://www.vpser.net/tag/%e6%af%94%e8%be%83" rel="tag">比较</a><br/>
<br/>
<img src="http://www.vpser.net/images/tuijian.gif"> <a href="http://www.vpser.net/usa-vps/">美国VPS推荐</a>  | <a href="http://shop63846532.taobao.com/">军哥代购 - 提供美国及海外VPS/VPN/域名代购，美元/欧元代付</a> QQ：503228080
</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.vpser.net/opt/apc-eaccelerator-xcache.html/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

