<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[nginx +php-cgi，apahce+php-cli，cgi的比较]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Mon, 27 Sep 2010 09:00:51 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	一，突发神精，来把它们三儿来比较<br/><br/>在网上看到好多文章说nginx有多么，多么好。不管好不好，看看测试结果在说，<br/><br/>1，nginx＋php-cgi说明<br/><br/>nginx我开启了11个进程，php-cgi我开启了10个进程<br/><br/>2，apache＋php-cgi说明<br/><br/>httpd我开启了11个进程，php-cgi我开启了10个进程<br/><br/>3，apache＋php-cli说明<br/><br/>没作任何限制<br/><br/>二，测试文件一test.php无逻辑文件<br/><br/>&nbsp;&nbsp; 1. &lt;?php&nbsp;&nbsp;<br/>&nbsp;&nbsp; 2. phpinfo();&nbsp;&nbsp;<br/>&nbsp;&nbsp; 3. ?&gt;&nbsp;&nbsp;<br/><br/>&lt;?php<br/>phpinfo();<br/>?&gt;<br/><br/>1，nginx+php-cgi<br/><br/>[root@BlackGhost zhangy]# /usr/local/bin/webbench -c 100 -t 30 http://localhost/test.php<br/>Webbench – Simple Web Benchmark 1.5<br/>Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.<br/><br/>Benchmarking: GET http://localhost/test.php<br/>100 clients, running 30 sec.<br/><br/>Speed=61598 pages/min, 1524550 bytes/sec.<br/>Requests: 30799 susceed, 0 failed.<br/><br/>2，apache+php-cgi<br/><br/>[root@BlackGhost zhangy]# /usr/local/bin/webbench -c 100 -t 30 http://localhost/test.php<br/>Webbench – Simple Web Benchmark 1.5<br/>Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.<br/><br/>Benchmarking: GET http://localhost/test.php<br/>100 clients, running 30 sec.<br/><br/>Speed=15000 pages/min, 371750 bytes/sec.<br/>Requests: 7500 susceed, 0 failed.<br/><br/>3，apache+php-cli<br/><br/>[root@BlackGhost conf]# /usr/local/bin/webbench -c 100 -t 30 http://localhost/test.php<br/>Webbench – Simple Web Benchmark 1.5<br/>Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.<br/><br/>Benchmarking: GET http://localhost/test.php<br/>100 clients, running 30 sec.<br/><br/>Speed=54618 pages/min, 1357257 bytes/sec.<br/>Requests: 27309 susceed, 0 failed.<br/><br/>三，测试文件二test1.php<br/>查看复制打印?<br/><br/>&nbsp;&nbsp; 1. &lt;?php&nbsp;&nbsp;<br/>&nbsp;&nbsp; 2. $con = mysql_connect(&quot;localhost&quot;,&quot;username&quot;,&quot;password&quot;);&nbsp;&nbsp;<br/>&nbsp;&nbsp; 3. if (!$con)&nbsp;&nbsp;<br/>&nbsp;&nbsp; 4.&nbsp;&nbsp; &#123;&nbsp;&nbsp;<br/>&nbsp;&nbsp; 5.&nbsp;&nbsp; die(&#039;Could not connect: &#039; . mysql_error());&nbsp;&nbsp;<br/>&nbsp;&nbsp; 6.&nbsp;&nbsp; &#125;&nbsp;&nbsp;<br/>&nbsp;&nbsp; 7.&nbsp;&nbsp; <br/>&nbsp;&nbsp; 8. mysql_select_db(&quot;test&quot;, $con);&nbsp;&nbsp;<br/>&nbsp;&nbsp; 9. mysql_query(&#039;set names utf8&#039;);&nbsp;&nbsp;<br/>&nbsp;&nbsp;10.&nbsp;&nbsp; <br/>&nbsp;&nbsp;11. $result = mysql_query(&quot;SELECT id, name, sex FROM test &quot;);&nbsp;&nbsp;<br/>&nbsp;&nbsp;12.&nbsp;&nbsp; <br/>&nbsp;&nbsp;13. while($row = mysql_fetch_array($result))&nbsp;&nbsp;<br/>&nbsp;&nbsp;14.&nbsp;&nbsp; &#123;&nbsp;&nbsp;<br/>&nbsp;&nbsp;15.&nbsp;&nbsp; echo $row[&#039;id&#039;] . &quot;+&quot; . $row[&#039;name&#039;].&quot;+&quot;.$row[&#039;sex&#039;];&nbsp;&nbsp;<br/>&nbsp;&nbsp;16.&nbsp;&nbsp; echo &quot; <br/>&nbsp;&nbsp;17. &quot;;&nbsp;&nbsp;<br/>&nbsp;&nbsp;18.&nbsp;&nbsp; &#125;&nbsp;&nbsp;<br/>&nbsp;&nbsp;19.&nbsp;&nbsp; <br/>&nbsp;&nbsp;20. mysql_close($con);&nbsp;&nbsp;<br/>&nbsp;&nbsp;21. ?&gt;&nbsp;&nbsp;<br/><br/>&lt;?php<br/>$con = mysql_connect(&quot;localhost&quot;,&quot;username&quot;,&quot;password&quot;);<br/>if (!$con)<br/>&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;die(&#039;Could not connect: &#039; . mysql_error());<br/>&nbsp;&nbsp;&#125;<br/><br/>mysql_select_db(&quot;test&quot;, $con);<br/>mysql_query(&#039;set names utf8&#039;);<br/><br/>$result = mysql_query(&quot;SELECT id, name, sex FROM test &quot;);<br/><br/>while($row = mysql_fetch_array($result))<br/>&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;echo $row[&#039;id&#039;] . &quot;+&quot; . $row[&#039;name&#039;].&quot;+&quot;.$row[&#039;sex&#039;];<br/>&nbsp;&nbsp;echo &quot;<br/>&quot;;<br/>&nbsp;&nbsp;&#125;<br/><br/>mysql_close($con);<br/>?&gt;<br/><br/>1，nginx+php-cgi<br/><br/>[root@BlackGhost zhangy]# /usr/local/bin/webbench -c 100 -t 30 http://localhost/test1.php<br/>Webbench – Simple Web Benchmark 1.5<br/>Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.<br/><br/>Benchmarking: GET http://localhost/test1.php<br/>100 clients, running 30 sec.<br/><br/>Speed=60716 pages/min, 324830 bytes/sec.<br/>Requests: 30358 susceed, 0 failed.<br/><br/>2，apache+php-cgi<br/><br/>[root@BlackGhost zhangy]# /usr/local/bin/webbench -c 100 -t 30 http://localhost/test1.php<br/>Webbench – Simple Web Benchmark 1.5<br/>Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.<br/><br/>Benchmarking: GET http://localhost/test1.php<br/>100 clients, running 30 sec.<br/><br/>Speed=12800 pages/min, 68906 bytes/sec.<br/>Requests: 6400 susceed, 0 failed.<br/><br/>3，apache+php-cli<br/><br/>[root@BlackGhost zhangy]# /usr/local/bin/webbench -c 100 -t 30 http://localhost/test1.php<br/>Webbench – Simple Web Benchmark 1.5<br/>Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.<br/><br/>Benchmarking: GET http://localhost/test1.php<br/>100 clients, running 30 sec.<br/><br/>Speed=78844 pages/min, 575834 bytes/sec.<br/>Requests: 39422 susceed, 0 failed.<br/><br/>四，个人分析<br/><br/>1，针对无逻辑文件，或者静态文件<br/><br/>在内存，cpu都没有最大化利用的情况下nginx＋php-cgi效果比apache+php-cli的效果好一点，而apache+php- cli是最大化用内存和cpu，由起可见，nginx＋php-cgi的对无罗辑或静态文件的解析要好很多。apache+php-cgi的效果很差，虽然php官方力挺php-cgi，但是根apache的配合效果不好。<br/><br/>2，针对逻辑复杂的文件<br/><br/>针对逻辑复杂的文件时，nginx＋php-cgi对php的解析的效果下降了，但是下降的不是很厉害。而apache＋php-cli对php的解析的效果去增强了，增加了很多，是原来的差不多1.5倍。nginx＋php-cgi在利用部分内存和CPU的情况下根apache＋php-cli对 php的解析都差不了多少，个人认为。nginx＋php-cgi要比apache＋php-cli要好。但是要想达到好多好多倍，我看难。<br/><br/>上面所做对比，不考虑11nginx，配合10php-cgi是否合理，这个就nginx来说，肯定不是很合理的。<br/>来源：http://blog.51yip.com/apachenginx/619.html
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] nginx +php-cgi，apahce+php-cli，cgi的比较]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>