<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[张宴的博客]]></title> 
<link>http://zyan.cc/index.php</link> 
<description><![CDATA[Web系统架构与底层研发]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[张宴的博客]]></copyright>
<item>
<link>http://zyan.cc/post/334/</link>
<title><![CDATA[Nginx + PHP5（FastCGI）生产环境跑PHP动态程序可超过“700次请求/秒”[原创]]]></title> 
<author>张宴 &lt;net@s135.com&gt;</author>
<category><![CDATA[Web服务器]]></category>
<pubDate>Wed, 26 Mar 2008 09:25:48 +0000</pubDate> 
<guid>http://zyan.cc/post/334/</guid> 
<description>
<![CDATA[ 
	　　我生产环境下的两台Nginx + PHP5（FastCGI）服务器，跑多个一般复杂的纯PHP动态程序，从Nginx的日志可以统计出，单台Nginx + PHP5（FastCGI）服务器跑PHP动态程序的处理能力已经超过“700次请求/秒”，相当于每天可以承受6000万（700*60*60*24=60480000）的访问量：<br/><br/>　　服务器①：DELL PowerEdge 1950（两颗 Intel(R) Xeon(R) 双核CPU 5120 @ 1.86GHz，4GB内存）<br/><br/>　　服务器②：DELL PowerEdge 1950（一颗 Intel(R) Xeon(R) 双核CPU 5140 @ 2.33GHz，4GB内存）<br/><br/>　　Web服务器：CentOS Linux 4.4 + Nginx 0.5.35 + PHP 5.2.6RC2（300 FastCGI Procees, unix-domain socket, with XCache）<br/><br/>　　PHP程序内容：大量Memcached读写、少量MySQL读操作、大量文件队列写操作，然后计算，生成供&lt;script type=&quot;text/javascript&quot; src=&quot;<a href="http://www.domain.com/abc.php?u=1&quot;&gt;&lt;/script&gt;" target="_blank">http://www.domain.com/abc.php?u=1&quot;&gt;&lt;/script&gt;</a>方式调用的JS代码或XML数据。<br/><br/>　　网卡流量：1.5M～3M/秒<br/><br/>　　请求数统计方式：从Nginx访问日志中，统计每分钟的第15秒共有多少条日志记录。<div class="quote"><div class="quote-title">引用</div><div class="quote-content">grep "25/Mar/2008:15:01:15" /data1/logs/nginx.log &#124; wc -l</div></div><br/><br/>　　<a href="http://zyan.cc/attachment/200803/nginx_php_pv.png" target="_blank"><img src="http://zyan.cc/attachment/200803/nginx_php_pv.png" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><br/>　　服务器的系统负载也不算高：<br/><br/>　　<a href="http://zyan.cc/attachment/200803/nginx_php_la.gif" target="_blank"><img src="http://zyan.cc/attachment/200803/nginx_php_la.gif" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><br/>　　总结：<br/>　　1、Nginx的处理能力超强，这块不是瓶颈。影响动态程序处理能力的因素主要在于PHP（FastCGI）。PHP（FastCGI）模式适用于执行时间较短的PHP程序，一般复杂的PHP程序执行时间应该在100ms以内，例如我的博客首页执行时间为38ms左右。假设一个PHP程序的执行时间为100ms，那么一个PHP（FastCGI）进程每秒可以处理完毕10个请求，300个FastCGI进程理论上每秒可以处理3000个请求。但是，在生产环境下，还将受到内存、系统负载等多方面的影响，例如300个PHP（FastCGI）进程需要占用2.4GB左右的内存，每秒处理超过1000个请求时，系统负载会飚升到100以上。因此，FastCGI的进程不是越多越好，而是够用就好。<br/><br/>　　2、使用PHP的XCache、APC等加速模块会提供速度10倍左右，降低系统负载50倍以上。<br/><br/>　　3、修改了spawn-fcgi，使它能够支持250个以上的FastCGI进程。<br/><br/>　　4、如果PHP直接对MySQL进行大量读写操作，速度是达不到“700 request/sec”的，PHP与MySQL之间需要一个中间层，这是关键的技术。<br/><br/>　　5、CPU的数量（多核算多个CPU，cat /proc/cpuinfo &#124;grep -c processor）越多，系统负载越低，每秒能处理的请求数也越多。<br/><br/>　　6、使用PHP 5.2.6RC2，因为它修正了PHP 5.2.5的“zend_mm_heap corrupted”错误BUG。PHP 5.2.5（FastCGI）在高并发请求情况下，经常会出现该错误。<br/><br/>　　7、有空我将写一篇针对CentOS Linux环境Nginx + PHP5（FastCGI）安装、配置的最新博文。<br/>Tags - <a href="http://zyan.cc/tags/linux/" rel="tag">linux</a> , <a href="http://zyan.cc/tags/php/" rel="tag">php</a> , <a href="http://zyan.cc/tags/mysql/" rel="tag">mysql</a> , <a href="http://zyan.cc/tags/nginx/" rel="tag">nginx</a> , <a href="http://zyan.cc/tags/xcache/" rel="tag">xcache</a> , <a href="http://zyan.cc/tags/apc/" rel="tag">apc</a> , <a href="http://zyan.cc/tags/fastcgi/" rel="tag">fastcgi</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/334/#blogcomment833</link>
<title><![CDATA[[评论] Nginx + PHP5（FastCGI）生产环境跑PHP动态程序可超过“700次请求/秒”[原创]]]></title> 
<author>Ajian &lt;5root@live.cn&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 26 Mar 2008 10:39:06 +0000</pubDate> 
<guid>http://zyan.cc/post/334/#blogcomment833</guid> 
<description>
<![CDATA[ 
	从你的Blog中学到不少东西。<br/>我从你上篇Nginx的文章做了实验Apache和Nginx的对比，从处理结果，服务器压力方面比较，结果是静态的处理能力Nginx比Apache强，PHP方面差不多，Nginx稍微差点。前提是没有做太多的优化。<br/>下次“CentOS Linux环境Nginx + PHP5（FastCGI）安装、配置”你的这篇文章出来，我再进行一次测试。<br/>会不会把相关Memcache的配置也加进来？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/334/#blogcomment834</link>
<title><![CDATA[[评论] Nginx + PHP5（FastCGI）生产环境跑PHP动态程序可超过“700次请求/秒”[原创]]]></title> 
<author>sx98083714 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 26 Mar 2008 11:52:14 +0000</pubDate> 
<guid>http://zyan.cc/post/334/#blogcomment834</guid> 
<description>
<![CDATA[ 
	“有空我将写一篇针对CentOS Linux环境Nginx + PHP5（FastCGI）安装、配置的最新博文”<br/>呵呵，期待呀！不过最近肯定忙着准备结婚吧，估计要很晚才能看到了，不过结婚第一呀！祝一切顺利，早日写出佳作，大家也跟着你一块进步了。
]]>
</description>
</item><item>
<link>http://zyan.cc/post/334/#blogcomment835</link>
<title><![CDATA[[评论] Nginx + PHP5（FastCGI）生产环境跑PHP动态程序可超过“700次请求/秒”[原创]]]></title> 
<author>草根网 &lt;chinaz1974@gmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 26 Mar 2008 13:46:50 +0000</pubDate> 
<guid>http://zyan.cc/post/334/#blogcomment835</guid> 
<description>
<![CDATA[ 
	<a href="http://www.20ju.com" target="_blank">好文，收藏至20ju.com</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/334/#blogcomment836</link>
<title><![CDATA[[评论] Nginx + PHP5（FastCGI）生产环境跑PHP动态程序可超过“700次请求/秒”[原创]]]></title> 
<author>Loveyuki &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 26 Mar 2008 14:59:56 +0000</pubDate> 
<guid>http://zyan.cc/post/334/#blogcomment836</guid> 
<description>
<![CDATA[ 
	能测试下 Lighttpd 的负载么？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/334/#blogcomment837</link>
<title><![CDATA[[评论] Nginx + PHP5（FastCGI）生产环境跑PHP动态程序可超过“700次请求/秒”[原创]]]></title> 
<author>大森林 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 26 Mar 2008 23:22:33 +0000</pubDate> 
<guid>http://zyan.cc/post/334/#blogcomment837</guid> 
<description>
<![CDATA[ 
	“有空我将写一篇针对CentOS Linux环境Nginx + PHP5（FastCGI）安装、配置的最新博文”<br/>最近正要用上，期待尽快能出炉，先谢谢啦~~
]]>
</description>
</item><item>
<link>http://zyan.cc/post/334/#blogcomment838</link>
<title><![CDATA[[评论] Nginx + PHP5（FastCGI）生产环境跑PHP动态程序可超过“700次请求/秒”[原创]]]></title> 
<author>chuan &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 27 Mar 2008 00:19:43 +0000</pubDate> 
<guid>http://zyan.cc/post/334/#blogcomment838</guid> 
<description>
<![CDATA[ 
	用了1年多的lighty了，感觉也很好，不知道Nginx对Lighty有什么优势没有？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/334/#blogcomment840</link>
<title><![CDATA[[评论] Nginx + PHP5（FastCGI）生产环境跑PHP动态程序可超过“700次请求/秒”[原创]]]></title> 
<author>nightsailer &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 27 Mar 2008 05:30:08 +0000</pubDate> 
<guid>http://zyan.cc/post/334/#blogcomment840</guid> 
<description>
<![CDATA[ 
	@zhangyan<br/><br/>3、修改了spawn-fcgi，使它能够支持250个以上的FastCGI进程。<br/>有没有试过 PHP-FPM补丁? &nbsp;我一直使用这个补丁<br/><a href="http://php-fpm.anight.org/" target="_blank">http://php-fpm.anight.org/</a><br/><br/>虽然需要对php打补丁,但实际效果感觉还是不错的.<br/><br/>6、使用PHP 5.2.6RC2，因为它修正了PHP 5.2.5的“zend_mm_heap corrupted”错误BUG。PHP 5.2.5（FastCGI）在高并发请求情况下，经常会出现该错误。<br/><br/>我年初作压力测试时候也一直被这个困扰,最后使用fpm缓解了一下, 后来使用snapshot, 还算好点了. 我估计使用FastCGI模式的并不多(相对mod_php).<br/><br/><br/>BTW: 这个博客的评论在Safari3.1下无法使用啊， 我重写了3次，又换了firefox <br/><br/><br/><br/>@chuan<br/><br/>Lighty我也一直用, 其实都合有千秋. 我看中nginx的是它的稳定性,此外就是负载均衡能力, 另外，配置比较灵活方便，易于管理，比如rewrite。 lighty如果做单一的图片服务器还是不错的，也有人将Lighty放在nginx后面，此外Lighty的稳定性不尽人意，没有nginx那样让人放心。
]]>
</description>
</item><item>
<link>http://zyan.cc/post/334/#blogcomment841</link>
<title><![CDATA[[评论] Nginx + PHP5（FastCGI）生产环境跑PHP动态程序可超过“700次请求/秒”[原创]]]></title> 
<author>top &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 27 Mar 2008 07:10:52 +0000</pubDate> 
<guid>http://zyan.cc/post/334/#blogcomment841</guid> 
<description>
<![CDATA[ 
	PHP-FPM 这个东西 要怎么使用啊 &nbsp;文档好少啊
]]>
</description>
</item><item>
<link>http://zyan.cc/post/334/#blogcomment842</link>
<title><![CDATA[[评论] Nginx + PHP5（FastCGI）生产环境跑PHP动态程序可超过“700次请求/秒”[原创]]]></title> 
<author>top &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 27 Mar 2008 07:12:31 +0000</pubDate> 
<guid>http://zyan.cc/post/334/#blogcomment842</guid> 
<description>
<![CDATA[ 
	3、修改了spawn-fcgi，使它能够支持250个以上的FastCGI进程。<br/><br/>这个要怎么修改啊
]]>
</description>
</item><item>
<link>http://zyan.cc/post/334/#blogcomment847</link>
<title><![CDATA[[评论] Nginx + PHP5（FastCGI）生产环境跑PHP动态程序可超过“700次请求/秒”[原创]]]></title> 
<author>代码罐头 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 28 Mar 2008 04:57:50 +0000</pubDate> 
<guid>http://zyan.cc/post/334/#blogcomment847</guid> 
<description>
<![CDATA[ 
	CentOS 5.x下环境的<br/>NGINX+PHP FASTCGI<br/><br/><a href="http://www.hiadmin.com/index.php?entry=entry080111-151926" target="_blank">http://www.hiadmin.com/index.php?entry=entry080111-151926</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/334/#blogcomment849</link>
<title><![CDATA[[评论] Nginx + PHP5（FastCGI）生产环境跑PHP动态程序可超过“700次请求/秒”[原创]]]></title> 
<author>LinYH &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 28 Mar 2008 13:11:15 +0000</pubDate> 
<guid>http://zyan.cc/post/334/#blogcomment849</guid> 
<description>
<![CDATA[ 
	过来窜门一下,我是一个对网站设计特别热爱的人,刚才在蓝风网络日志看您的BLOG,就进来看了一下,觉得您这里有好多东西学,所以就顺便在您这申请了友链
]]>
</description>
</item><item>
<link>http://zyan.cc/post/334/#blogcomment855</link>
<title><![CDATA[[评论] Nginx + PHP5（FastCGI）生产环境跑PHP动态程序可超过“700次请求/秒”[原创]]]></title> 
<author>tecer &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sun, 30 Mar 2008 02:55:21 +0000</pubDate> 
<guid>http://zyan.cc/post/334/#blogcomment855</guid> 
<description>
<![CDATA[ 
	www.newsmth.net用的Nginx，三天两头重启，总平均访问2万，也就2万个迸发连接吧？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/334/#blogcomment856</link>
<title><![CDATA[[评论] Nginx + PHP5（FastCGI）生产环境跑PHP动态程序可超过“700次请求/秒”[原创]]]></title> 
<author>tecer &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sun, 30 Mar 2008 02:59:56 +0000</pubDate> 
<guid>http://zyan.cc/post/334/#blogcomment856</guid> 
<description>
<![CDATA[ 
	看看新水木的服务器，同时在线，最多22000，用的是nginx0.5.35，三天两头重启。
]]>
</description>
</item><item>
<link>http://zyan.cc/post/334/#blogcomment869</link>
<title><![CDATA[[评论] Nginx + PHP5（FastCGI）生产环境跑PHP动态程序可超过“700次请求/秒”[原创]]]></title> 
<author>刀马 &lt;frankelma@gmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 31 Mar 2008 09:55:45 +0000</pubDate> 
<guid>http://zyan.cc/post/334/#blogcomment869</guid> 
<description>
<![CDATA[ 
	博主有没有比较过lighttpd和nginx？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/334/#blogcomment873</link>
<title><![CDATA[[评论] Nginx + PHP5（FastCGI）生产环境跑PHP动态程序可超过“700次请求/秒”[原创]]]></title> 
<author>David &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 31 Mar 2008 14:58:09 +0000</pubDate> 
<guid>http://zyan.cc/post/334/#blogcomment873</guid> 
<description>
<![CDATA[ 
	感謝分享~~經常來您的Blog觀看您寫的技術文章~希望您能多寫一點 :-)<br/>ps.祝新婚愉快!!
]]>
</description>
</item>
</channel>
</rss>