<?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"
	>

<channel>
	<title>互联网，请记住我 &#187; php技术</title>
	<atom:link href="http://www.162cm.com/archives/category/php%e6%80%a7%e8%83%bd/feed" rel="self" type="application/rss+xml" />
	<link>http://www.162cm.com</link>
	<description>一米六二的北漂生活</description>
	<pubDate>Tue, 18 Nov 2008 14:09:56 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>用fastCGI协议进行RPC调用</title>
		<link>http://www.162cm.com/archives/560.html</link>
		<comments>http://www.162cm.com/archives/560.html#comments</comments>
		<pubDate>Thu, 06 Dec 2007 12:57:13 +0000</pubDate>
		<dc:creator>xurenlu</dc:creator>
		
		<category><![CDATA[php性能]]></category>

		<category><![CDATA[php技术]]></category>

		<category><![CDATA[fastcgi]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[rpc]]></category>

		<guid isPermaLink="false">http://www.162cm.com/archives/560.html</guid>
		<description><![CDATA[近来由于业务量急剧增长,业务种类越来越多,RPC混乱问题就凸现出来.
具体表现是:
a1,a2,a3,a4 为一组服务器,为用户提供A服务.
b1,b2,b3为一组服务器,为用户提供B服务.
c1,c2,c3为一组服务器,为用户提供C服务.
最初各服务器各自服务是不太相关的.随着业务拓展,用户提出新的需求,我们需要
在A服务中调用B组服务器的API接口.
&#8230;.
最后我们发现这样一个现象:
用户请求a1 提供服务.a1发现他需要知道另一些数据,于是调用b2的rpc服务.但是b2
上这个数据又需要c3的RPC.结果c3又需要a2来提供一些数据&#8230;.
我们的远程调用调来调去,最后把自己调晕了.
于是我开始考虑一种解决方案。
首先当然是：对远程调用加以控制和规范，避免不必要的远程调用。
接着我注意到，我们利用CURL来通过http通道进行远程调用其实是没必要的。我可以在做远程调用时，走FastCGI协议。
说干就干:
第一步：建立一个fastCGI:spawn-php
#!/bin/bash
&#160;
## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI=&#34;/home/y/opt/lighttpd/bin/spawn-fcgi&#34;
&#160;
## ABSOLUTE path to the PHP binary
FCGIPROGRAM=&#34;/home/y/opt/php/bin/php-cgi&#34;
&#160;
## TCP port to which to bind on localhost
FCGIPORT=&#34;1026&#34;
&#160;
## number of PHP children to spawn
PHP_FCGI_CHILDREN=10
&#160;
## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=1000
&#160;
## IP addresses from which PHP should access server connections
FCGI_WEB_SERVER_ADDRS=&#34;127.0.0.1,192.168.2.10&#34;
&#160;
# allowed environment variables, [...]]]></description>
			<content:encoded><![CDATA[<p>近来由于业务量急剧增长,业务种类越来越多,RPC混乱问题就凸现出来.<br />
具体表现是:<br />
a1,a2,a3,a4 为一组服务器,为用户提供A服务.<br />
b1,b2,b3为一组服务器,为用户提供B服务.<br />
c1,c2,c3为一组服务器,为用户提供C服务.<br />
最初各服务器各自服务是不太相关的.随着业务拓展,用户提出新的需求,我们需要<br />
在A服务中调用B组服务器的API接口.<br />
&#8230;.<br />
最后我们发现这样一个现象:<br />
用户请求a1 提供服务.a1发现他需要知道另一些数据,于是调用b2的rpc服务.但是b2<br />
上这个数据又需要c3的RPC.结果c3又需要a2来提供一些数据&#8230;.<br />
我们的远程调用调来调去,最后把自己调晕了.</p>
<p>于是我开始考虑一种解决方案。<br />
首先当然是：对远程调用加以控制和规范，避免不必要的远程调用。<br />
接着我注意到，我们利用CURL来通过http通道进行远程调用其实是没必要的。我可以在做远程调用时，走FastCGI协议。</p>
<p>说干就干:<br />
第一步：建立一个fastCGI:<a href="http://www.162cm.com/wp-content/uploads/2007/12/spawn-php.txt" title="spawn-php">spawn-php</a></p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">#!/bin/bash</li>
<li>&nbsp;</li>
<li>## ABSOLUTE path to the spawn-fcgi binary</li>
<li>SPAWNFCGI=&quot;/home/y/opt/lighttpd/bin/spawn-fcgi&quot;</li>
<li>&nbsp;</li>
<li>## ABSOLUTE path to the PHP binary</li>
<li>FCGIPROGRAM=&quot;/home/y/opt/php/bin/php-cgi&quot;</li>
<li>&nbsp;</li>
<li>## TCP port to which to bind on localhost</li>
<li>FCGIPORT=&quot;1026&quot;</li>
<li>&nbsp;</li>
<li>## number of PHP children to spawn</li>
<li>PHP_FCGI_CHILDREN=10</li>
<li>&nbsp;</li>
<li>## maximum number of requests a single PHP process can serve before it is restarted</li>
<li>PHP_FCGI_MAX_REQUESTS=1000</li>
<li>&nbsp;</li>
<li>## IP addresses from which PHP should access server connections</li>
<li>FCGI_WEB_SERVER_ADDRS=&quot;127.0.0.1,192.168.2.10&quot;</li>
<li>&nbsp;</li>
<li># allowed environment variables, separated by spaces</li>
<li>ALLOWED_ENV=&quot;ORACLE_HOME PATH USER&quot;</li>
<li>&nbsp;</li>
<li>## if this script is run as root, switch to the following user</li>
<li>USERID=y</li>
<li>GROUPID=y</li>
<li>&nbsp;</li>
<li>################## no config below this line</li>
<li>&nbsp;</li>
<li>if test x$PHP_FCGI_CHILDREN = x; then</li>
<li>PHP_FCGI_CHILDREN=5</li>
<li>fi</li>
<li>&nbsp;</li>
<li>export PHP_FCGI_MAX_REQUESTS</li>
<li>export FCGI_WEB_SERVER_ADDRS</li>
<li>&nbsp;</li>
<li>ALLOWED_ENV=&quot;$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS&quot;</li>
<li>&nbsp;</li>
<li>if test x$UID = x0; then</li>
<li>EX=&quot;$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -u $USERID -g $GROUPID -C $PHP_FCGI_CHILDREN&quot;</li>
<li>else</li>
<li>EX=&quot;$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -C $PHP_FCGI_CHILDREN&quot;</li>
<li>fi</li>
<li>&nbsp;</li>
<li># copy the allowed environment variables</li>
<li>E=</li>
<li>&nbsp;</li>
<li>for i in $ALLOWED_ENV; do</li>
<li>E=&quot;$E $i=${!i}&quot;</li>
<li>done</li>
<li>&nbsp;</li>
<li># clean the environment and set up a new one</li>
<li>env - $E $EX</li></ol></div>
<p>2.接着我们建立这样的文件：<a href="http://www.162cm.com/wp-content/uploads/2007/12/http.txt" title="http.txt">http.txt</a></p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">for($i=0;$i&amp;lt;100;$i++)</li>
<li>{</li>
<li>echo rand();</li>
<li>echo '....Scene of shooting at Nebraska shopping centre</li>
<li>Eight killed in Nebraska shooting</li>
<li>A gunman opens fire in a shopping centre in the US state of Nebraska, killing at least eight people.</li>
<li>Scene of shooting at Nebraska shopping centre</li>
<li>Eight killed in Nebraska shooting</li>
<li>A gunman opens fire in a shopping centre in the US state of Nebraska, killing at least eight people.</li>
<li>Scene of shooting at Nebraska shopping centre</li>
<li>Eight killed in Nebraska shooting</li>
<li>A gunman opens fire in a shopping centre in the US state of Nebraska, killing at least eight people.</li>
<li>Scene of shooting at Nebraska shopping centre</li>
<li>Eight killed in Nebraska shooting</li>
<li>A gunman opens fire in a shopping centre in the US state of Nebraska, killing at least eight people.</li>
<li>';</li>
<li>}</li>
<li>print &quot;done!&quot;;</li></ol></div>
<p>这个做为是远程接口。<br />
3.下面比较CURL和fastCGI两种访问remote API的方式:<br />
A:走FastCGI:</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">include &quot;./mod_fcgi.php&quot;;</li>
<li>$fcgi=new mod_fcgi();</li>
<li>$args=&quot;127.0.0.1:1026&quot;;</li>
<li>$filename=&quot;/home/y/www/qps/http.php&quot;;</li>
<li>$fcgi-&amp;gt;parser_open($args,$filename,$rq_err,$cgi_headers);</li>
<li>print($fcgi-&amp;gt;parsed_output);</li>
<li>echo &quot;\n=============\n&quot;;</li></ol></div>
<p>B:走CURL通道:</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">include &quot;./curl.php&quot;;</li>
<li>$curl=&amp;amp; new CURL();</li>
<li>echo $curl-&amp;gt;get(&quot;http://localhost/qps/http.php&quot;);</li>
<li>echo &quot;\n=============\n&quot;;</li></ol></div>
<p>4我们比较FCGI方式和CURL方式的差异：<br />
FCGI方式进行远程调用的QPS:</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">Total transferred:&nbsp; &nbsp; &nbsp; 249306 bytes</li>
<li>HTML transferred:&nbsp; &nbsp; &nbsp; &nbsp;244410 bytes</li>
<li>Requests per second:&nbsp; &nbsp; 275.77 [#/sec] (mean)</li>
<li>Time per request:&nbsp; &nbsp; &nbsp; &nbsp;3.626 [ms] (mean)</li>
<li>Time per request:&nbsp; &nbsp; &nbsp; &nbsp;3.626 [ms] (mean, across all concurrent requests)</li>
<li>Transfer rate:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2233.76 [Kbytes/sec] received</li></ol></div>
<p>HTTP通道进行远程调用的QPS:</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">Total transferred:&nbsp; &nbsp; &nbsp; 2244515 bytes</li>
<li>HTML transferred:&nbsp; &nbsp; &nbsp; &nbsp;2240015 bytes</li>
<li>Requests per second:&nbsp; &nbsp; 204.18 [#/sec] (mean)</li>
<li>Time per request:&nbsp; &nbsp; &nbsp; &nbsp;4.898 [ms] (mean)</li>
<li>Time per request:&nbsp; &nbsp; &nbsp; &nbsp;4.898 [ms] (mean, across all concurrent requests)</li>
<li>Transfer rate:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 14911.66 [Kbytes/sec] received</li></ol></div>
<p>经过多次比较，确认用fastCGI通道时，效率比http方式要高。<br />
但是&#8230;.这个差别并不大，而且,使用lighttpd的spawn-cgi来充当fastcgi的守护进程，还不是特别稳定。<br />
另外，经过我的测试，只有当远程调用的结果有较多的输出时，FastCGI协议与HTTP协议相比才有优势。在通过网络传输的数据不多的情况下（就是http.php几乎没有输出的情况下），用CURL来调远端调用，反而比FastCGI方式慢（显而易见，mod_fcgi是自行封装的用PHP的socket函数来进行网络操作的class,而Curl是一个编译了的php扩展).<br />
因此，我忙活了半天，最后得出的结论是，目前还不能在公司大规模加以运用。<br />
但是对于小型企业，创业型公司来说，这种效率对比还是很有用的，可以加以挖掘。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.162cm.com/archives/560.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>php文章收集贴</title>
		<link>http://www.162cm.com/archives/498.html</link>
		<comments>http://www.162cm.com/archives/498.html#comments</comments>
		<pubDate>Sun, 14 Oct 2007 05:42:16 +0000</pubDate>
		<dc:creator>xurenlu</dc:creator>
		
		<category><![CDATA[php技术]]></category>

		<category><![CDATA[未分类]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.162cm.com/php_wenzhang_shouji</guid>
		<description><![CDATA[ab测试数据会跳舞
*php中静态方法,函数,对象方法性能测试
*php-APC介绍
*利用web应用中的不均衡性重构你的技术细节
*把握web 开发的平衡与不平衡
*php高手之路之—狐假虎威
*PHP高手之路之—折柳为剑
*php高手之路之—纵横天下
*php高手之路之—万人之术
*php高手之路之—屠龙宝刀
*php高手之路之—绝世秘籍
*php高手之路之—返樸归真
*用PHP5.2+APC实现超酷的PHP进度条
*道可道，非常道—PHP模板技术
select id,title from * 与select * from **的速度测试。
*为什么SELECT col1,col2,col3,col4 会比SELECT * 慢?

]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.162cm.com/archives/457.html" target="_top">ab测试数据会跳舞</a><br />
*<a href="http://www.162cm.com/archives/456.html" target="_top">php中静态方法,函数,对象方法性能测试</a><br />
*<a href="http://www.162cm.com/archives/451.html" target="_top">php-APC介绍</a><br />
*<a href="http://www.162cm.com/archives/414.html" target="_top">利用web应用中的不均衡性重构你的技术细节</a><br />
*<a href="http://www.162cm.com/archives/388.html" target="_top">把握web 开发的平衡与不平衡</a><br />
*<a href="http://www.162cm.com/archives/392.html" target="_top">php高手之路之—狐假虎威</a><br />
*<a href="http://www.162cm.com/archives/393.html" target="_top">PHP高手之路之—折柳为剑</a><br />
*<a href="http://www.162cm.com/archives/394.html" target="_top">php高手之路之—纵横天下</a><br />
*<a href="http://www.162cm.com/archives/395.html" target="_top">php高手之路之—万人之术</a><br />
*<a href="http://www.162cm.com/archives/396.html" target="_top">php高手之路之—屠龙宝刀</a><br />
*<a href="http://www.162cm.com/archives/397.html" target="_top">php高手之路之—绝世秘籍</a><br />
*<a href="http://www.162cm.com/archives/398.html" target="_top">php高手之路之—返樸归真</a><br />
*<a href="http://www.162cm.com/archives/406.html" target="_top">用PHP5.2+APC实现超酷的PHP进度条</a><br />
*<a href="http://www.162cm.com/archives/298.html" target="_top">道可道，非常道—PHP模板技术</a><br />
<strong><a href="http://www.162cm.com/archives/283.html" target="_top">select id,title from *</a></strong><a href="http://www.162cm.com/archives/283.html" target="_top"> 与select * from **的速度测试。</a><br />
*<a href="http://www.162cm.com/archives/492.html" target="_top">为什么SELECT col1,col2,col3,col4 会比SELECT * 慢?</a></p>
<h3><a name="Contact"></a><a name="Contact_"></a></h3>
]]></content:encoded>
			<wfw:commentRss>http://www.162cm.com/archives/498.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>用ab来做性能测评好像不公平吧?</title>
		<link>http://www.162cm.com/archives/457.html</link>
		<comments>http://www.162cm.com/archives/457.html#comments</comments>
		<pubDate>Tue, 21 Aug 2007 15:47:14 +0000</pubDate>
		<dc:creator>xurenlu</dc:creator>
		
		<category><![CDATA[php性能]]></category>

		<category><![CDATA[php技术]]></category>

		<category><![CDATA[ab]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[性能]]></category>

		<guid isPermaLink="false">http://www.162cm.com/archives/457.html</guid>
		<description><![CDATA[我的师兄,从某种程度上说也是我php方面的师父,和他的同事做了测评,分别是针对php4,php5的性能对比和function,class的性能对比的。
这里是师兄的对比结果
师兄的同事做的测评
但是我不认为用ab来做出的测试是合理的.理由:用ab来测试时,结果好像总似是在跳舞一样.做为证据,我将我的notebook依文本方式重启,用ab来测lighttpd的表现.
具体环境:
Haier H40S Notebook
RAM:1.5G
CPU:CY 1.6GHz
硬盘:60G,(具体型号什么的不清楚,列个60G表示不是SCSI硬盘)
OS:Fedora Core 7.0(Moonshine)
web server:lighttpd 1.4.15
测试工具:ab
X环境:未运行X server
命令:ab -n 10000 -c 50 http://localhost:8181/
第一份结果:
This is ApacheBench, Version 2.0.40-dev &#38;lt;$Revision: 1.146 $&#38;gt; apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Server Software:        lighttpd/1.4.15
Server Hostname:        [...]]]></description>
			<content:encoded><![CDATA[<p>我的师兄,从某种程度上说也是我php方面的师父,和他的同事做了测评,分别是针对php4,php5的性能对比和function,class的性能对比的。<br />
<a href="http://chin.bokee.com/6398886.html" target="_blank">这里是师兄的对比结果</a><br />
<a href="http://soft.zdnet.com.cn/software_zone/2007/0806/446249.shtml" target="_blank">师兄的同事做的测评</a><br />
但是我不认为用ab来做出的测试是合理的.理由:用ab来测试时,结果好像总似是在跳舞一样.做为证据,我将我的notebook依文本方式重启,用ab来测lighttpd的表现.<br />
具体环境:<br />
Haier H40S Notebook<br />
RAM:1.5G<br />
CPU:CY 1.6GHz<br />
硬盘:60G,(具体型号什么的不清楚,列个60G表示不是SCSI硬盘)<br />
OS:Fedora Core 7.0(Moonshine)<br />
web server:lighttpd 1.4.15<br />
测试工具:ab<br />
X环境:未运行X server<br />
命令:ab -n 10000 -c 50 http://localhost:8181/<br />
第一份结果:</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">This is ApacheBench, Version 2.0.40-dev &amp;lt;$Revision: 1.146 $&amp;gt; apache-2.0</li>
<li>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/</li>
<li>Copyright 2006 The Apache Software Foundation, http://www.apache.org/</li></ol></div>
<p>Benchmarking localhost (be patient)</p>
<p>Server Software:        lighttpd/1.4.15<br />
Server Hostname:        localhost<br />
Server Port:            8181</p>
<p>Document Path:          /<br />
Document Length:        345 bytes</p>
<p>Concurrency Level:      50<br />
Time taken for tests:   1.786830 seconds<br />
Complete requests:      10000<br />
Failed requests:        0<br />
Write errors:           0<br />
Non-2xx responses:      10000<br />
Total transferred:      4980000 bytes<br />
HTML transferred:       3450000 bytes<br />
Requests per second:    5596.50 [#/sec] (mean)<br />
Time per request:       8.934 [ms] (mean)<br />
Time per request:       0.179 [ms] (mean, across all concurrent requests)<br />
Transfer rate:          2721.58 [Kbytes/sec] received</p>
<p>Connection Times (ms)<br />
min  mean[+/-sd] median   max<br />
Connect:        0    3   2.6      4       8<br />
Processing:     1    4   0.7      5       6<br />
Waiting:        0    1   1.7      2       5<br />
Total:          5    8   2.2      8      13<br />
WARNING: The median and mean for the processing time are not within a normal deviation<br />
These results are probably not that reliable.</p>
<p>Percentage of the requests served within a certain time (ms)<br />
50%      8<br />
66%     10<br />
75%     10<br />
80%     11<br />
90%     11<br />
95%     12<br />
98%     12<br />
99%     12<br />
100%     13 (longest request)</p>
<p>这里的结果是Requests per second:    5596.50 [#/sec] (mean)(插一句,lighttpd的性能真是好,用apache从来没上过3000)<br />
第二份ab -n 10000 -c 50的结果:</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">This is ApacheBench, Version 2.0.40-dev &amp;lt;$Revision: 1.146 $&amp;gt; apache-2.0</li>
<li>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/</li>
<li>Copyright 2006 The Apache Software Foundation, http://www.apache.org/</li></ol></div>
<p>Benchmarking localhost (be patient)</p>
<p>Server Software:        lighttpd/1.4.15<br />
Server Hostname:        localhost<br />
Server Port:            8181</p>
<p>Document Path:          /<br />
Document Length:        345 bytes</p>
<p>Concurrency Level:      50<br />
Time taken for tests:   1.313719 seconds<br />
Complete requests:      10000<br />
Failed requests:        0<br />
Write errors:           0<br />
Non-2xx responses:      10011<br />
Total transferred:      4985478 bytes<br />
HTML transferred:       3453795 bytes<br />
Requests per second:    7611.98 [#/sec] (mean)<br />
Time per request:       6.569 [ms] (mean)<br />
Time per request:       0.131 [ms] (mean, across all concurrent requests)<br />
Transfer rate:          3705.51 [Kbytes/sec] received</p>
<p>Connection Times (ms)<br />
min  mean[+/-sd] median   max<br />
Connect:        0    1   1.0      1       5<br />
Processing:     1    5   2.0      5      32<br />
Waiting:        0    3   1.8      3      30<br />
Total:          1    6   2.1      6      35</p>
<p>Percentage of the requests served within a certain time (ms)<br />
50%      6<br />
66%      6<br />
75%      6<br />
80%      6<br />
90%      7<br />
95%      8<br />
98%     10<br />
99%     11<br />
100%     35 (longest request)</p>
<p>结果表明RPS是Requests per second:    7611.98 [#/sec] (mean).<br />
第三份结果:</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">This is ApacheBench, Version 2.0.40-dev &amp;lt;$Revision: 1.146 $&amp;gt; apache-2.0</li>
<li>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/</li>
<li>Copyright 2006 The Apache Software Foundation, http://www.apache.org/</li></ol></div>
<p>Benchmarking localhost (be patient)</p>
<p>Server Software:        lighttpd/1.4.15<br />
Server Hostname:        localhost<br />
Server Port:            8181</p>
<p>Document Path:          /<br />
Document Length:        345 bytes</p>
<p>Concurrency Level:      50<br />
Time taken for tests:   1.300247 seconds<br />
Complete requests:      10000<br />
Failed requests:        0<br />
Write errors:           0<br />
Non-2xx responses:      10009<br />
Total transferred:      4984482 bytes<br />
HTML transferred:       3453105 bytes<br />
Requests per second:    7690.85 [#/sec] (mean)<br />
Time per request:       6.501 [ms] (mean)<br />
Time per request:       0.130 [ms] (mean, across all concurrent requests)<br />
Transfer rate:          3743.14 [Kbytes/sec] received</p>
<p>Connection Times (ms)<br />
min  mean[+/-sd] median   max<br />
Connect:        0    1   1.0      1       5<br />
Processing:     1    4   1.4      5      11<br />
Waiting:        0    2   1.1      3       8<br />
Total:          1    6   1.2      6      14</p>
<p>Percentage of the requests served within a certain time (ms)<br />
50%      6<br />
66%      6<br />
75%      6<br />
80%      6<br />
90%      7<br />
95%      9<br />
98%     10<br />
99%     11<br />
100%     14 (longest request)</p>
<p>RPS结果是Requests per second:    7690.85 [#/sec] (mean).<br />
第四份结果是:</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">This is ApacheBench, Version 2.0.40-dev &amp;lt;$Revision: 1.146 $&amp;gt; apache-2.0</li>
<li>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/</li>
<li>Copyright 2006 The Apache Software Foundation, http://www.apache.org/</li></ol></div>
<p>Benchmarking localhost (be patient)</p>
<p>Server Software:        lighttpd/1.4.15<br />
Server Hostname:        localhost<br />
Server Port:            8181</p>
<p>Document Path:          /<br />
Document Length:        345 bytes</p>
<p>Concurrency Level:      50<br />
Time taken for tests:   1.315784 seconds<br />
Complete requests:      10000<br />
Failed requests:        0<br />
Write errors:           0<br />
Non-2xx responses:      10033<br />
Total transferred:      4996434 bytes<br />
HTML transferred:       3461385 bytes<br />
Requests per second:    7600.03 [#/sec] (mean)<br />
Time per request:       6.579 [ms] (mean)<br />
Time per request:       0.132 [ms] (mean, across all concurrent requests)<br />
Transfer rate:          3708.06 [Kbytes/sec] received</p>
<p>Connection Times (ms)<br />
min  mean[+/-sd] median   max<br />
Connect:        0    1   1.2      1       8<br />
Processing:     1    4   1.4      5      11<br />
Waiting:        0    2   1.1      3       8<br />
Total:          1    6   1.4      6      15</p>
<p>Percentage of the requests served within a certain time (ms)<br />
50%      6<br />
66%      6<br />
75%      6<br />
80%      6<br />
90%      7<br />
95%      9<br />
98%     11<br />
99%     12<br />
100%     15 (longest request)</p>
<p>结果是Requests per second:    7600.03 [#/sec] (mean).<br />
第五份结果是:</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">This is ApacheBench, Version 2.0.40-dev &amp;lt;$Revision: 1.146 $&amp;gt; apache-2.0</li>
<li>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/</li>
<li>Copyright 2006 The Apache Software Foundation, http://www.apache.org/</li></ol></div>
<p>Benchmarking localhost (be patient)</p>
<p>Server Software:        lighttpd/1.4.15<br />
Server Hostname:        localhost<br />
Server Port:            8181</p>
<p>Document Path:          /<br />
Document Length:        345 bytes</p>
<p>Concurrency Level:      50<br />
Time taken for tests:   1.812989 seconds<br />
Complete requests:      10000<br />
Failed requests:        0<br />
Write errors:           0<br />
Non-2xx responses:      10000<br />
Total transferred:      4980000 bytes<br />
HTML transferred:       3450000 bytes<br />
Requests per second:    5515.75 [#/sec] (mean)<br />
Time per request:       9.065 [ms] (mean)<br />
Time per request:       0.181 [ms] (mean, across all concurrent requests)<br />
Transfer rate:          2682.31 [Kbytes/sec] received</p>
<p>Connection Times (ms)<br />
min  mean[+/-sd] median   max<br />
Connect:        0    3   2.7      4       9<br />
Processing:     1    4   0.8      5       6<br />
Waiting:        0    1   1.7      2       5<br />
Total:          5    8   2.3      9      13<br />
WARNING: The median and mean for the processing time are not within a normal deviation<br />
These results are probably not that reliable.</p>
<p>Percentage of the requests served within a certain time (ms)<br />
50%      9<br />
66%     10<br />
75%     10<br />
80%     11<br />
90%     12<br />
95%     12<br />
98%     12<br />
99%     12<br />
100%     13 (longest request)</p>
<p>RPS结果是Requests per second:    5515.75 [#/sec] (mean);</p>
<p>可以看到,同是ab -n 10000 -c 50 http://localhost:8181/,结果大不一样,不仅分为7600RPS和5500RPS两档,而各档中具体数据也不一样.这个结果可以理解,OS中总是会有各种各样的消息要处理,影响具体数据结果也很正常.<br />
因此,谢华亮(sir?mm?)的测试用ab的结果来进行php4,php5的性能比较是不太对的.至少目前看来,我没有从他的文章中看到他进行了多次ab测评后取结果的平均值.但是他列出来这样一个结果:</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">版本	函数测试	不实例化类	实例化类	类的继承</li>
<li>PHP 4.4.2	1047.23/rps		1034.98/rps		1006.14/rps		992.95/rps</li>
<li>PHP 5.2.1	1176.06/rps		1197.17/rps		 1187.93/rps	1128.54/rps</li></ol></div>
<p>这大致可以说明,php5.2确实是比php4.4.2要快.但是从1197.17&gt;1176.06得出php5的类跑得比functiong还快,我不这么认为.只是21个request的差别,太小了,ab测试的随便一个风吹草吹就行了(而且说class比function要快,严重地伤害了我的感情,哈哈)&#8230;<br />
嗯,先整这么多.有空好好研究一下,如何对web程序进行性能测评.<br />
另外,有空见到这两位兄台,好好争论一番.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.162cm.com/archives/457.html/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
