<?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/297/</link>
<title><![CDATA[Nginx 0.5.31 + PHP 5.2.4（FastCGI）搭建可承受3万以上并发连接数，胜过Apache 10倍的Web服务器[原创]]]></title> 
<author>张宴 &lt;net@s135.com&gt;</author>
<category><![CDATA[Web服务器]]></category>
<pubDate>Mon, 24 Sep 2007 10:56:20 +0000</pubDate> 
<guid>http://zyan.cc/post/297/</guid> 
<description>
<![CDATA[ 
	　　<strong><span style="font-size: 14px;"><span style="color: #FF0000;">本文已有最新版本：</span></span></strong><br/><br/>　　<strong><span style="font-size: 14px;"><span style="color: #FF0000;">请点击</span>《<a href="http://blog.zyan.cc/nginx_php_v6/" target="_blank">Nginx 0.8.x + PHP 5.2.13（FastCGI）搭建胜过Apache十倍的Web服务器（第6版）</a>》</span></strong><br/><br/><hr/><br/><br/>　　[文章作者：张宴 本文版本：v1.3 最后修改：<span style="color: #FF0000;">2007.11.06</span> 转载请注明出处：<a href="http://blog.zyan.cc" target="_blank">http://blog.zyan.cc</a>]<br/><br/>　　<a href="http://www.nginx.net/" target="_blank">Nginx</a> ("engine x") 是一个高性能的 HTTP 和反向代理服务器，也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的，它已经在该站点运行超过两年半了。Igor 将源代码以类BSD许可证的形式发布。<br/><br/>　　Nginx 的中文维基：<a href="http://wiki.codemongers.com/NginxChs" target="_blank">http://wiki.codemongers.com/NginxChs</a><br/><br/>　　在高并发连接的情况下，Nginx是Apache服务器不错的替代品。Nginx同时也可以作为7层负载均衡服务器来使用。根据我的测试结果，<strong>Nginx 0.5.31 + PHP 5.2.4 (FastCGI) 可以承受3万以上的并发连接数，相当于同等环境下Apache的10倍</strong>。<br/><br/>　　以下是 Nginx 0.5.31 + PHP 5.2.4 (FastCGI) 服务器在3万并发连接下的TCP状况：<br/><div style="border-left: 0px dashed #D6C094; margin: 5px; padding: 3px; margin-bottom:0px; border: 1px dashed #00a0c6; background-color: #ffffff;">netstat -n &#124; awk '/^tcp/ &#123;++S[$NF]&#125; END &#123;for(a in S) print a, S[a]&#125;'</div><br/>　　各种状态TCP连接数如下（各项值所代表的含义见我的另一篇文章《<a href="read.php/269.htm" target="_blank">查看Apache并发请求数及其TCP连接状态</a>》）：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">LAST_ACK 1<br/>SYN_RECV 991<br/>CLOSE_WAIT 1<br/>ESTABLISHED 18789<br/>FIN_WAIT1 1478<br/>FIN_WAIT2 181<br/>TIME_WAIT 506</div></div><br/>　　根据我的经验，4GB内存的服务器+Apache（prefork模式）一般只能处理3000个并发连接，因为它们将占用3GB以上的内存，还得为系统预留1GB的内存。我曾经就有两台Apache服务器，因为在配置文件中设置的MaxClients为4000，当Apache并发连接数达到3800时，导致服务器内存和Swap空间用满而崩溃。<br/><br/>　　而这台 Nginx 0.5.31 + PHP 5.2.4 (FastCGI) 服务器在3万并发连接下，开启的10个Nginx进程消耗100M内存（20MB*10=100M），开启的250个php-cgi进程消耗1G内存（4MB*250≈1GB），加上系统自身消耗的内存，总共才消耗2GB内存。如果服务器内存较小，完全可以只开启25个php-cgi进程，这样php-cgi消耗的总内存数才100M。在开启25个php-cgi进程的情况下，每分钟的处理能力只比开启250个php-cgi进程时低了不到一半。<br/><br/>　　以下为 Nginx 0.5.31 + PHP 5.2.4 (FastCGI) 服务器在3万并发连接下，开启的10个Nginx进程和250个php-cgi进程时的系统负载情况：<br/>　　<a href="http://zyan.cc/attachment/200709/top_nginx.gif" target="_blank"><img src="http://zyan.cc/attachment/200709/top_nginx.gif" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><hr/><br/>　　安装步骤：<br/>　　（系统要求：Linux 2.6+ 内核，本文中的Linux操作系统为CentOS 4.4）<br/><br/>　　一、获取相关开源程序：<br/>　　1、下载程序源码包到当前目录：<br/>　　本文中提到的所有开源软件为截止到2007年9月21日的最新稳定版。我将它们打了两个压缩包。<br/><br/>............<br/><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/nginx/" rel="tag">nginx</a> , <a href="http://zyan.cc/tags/mysql/" rel="tag">mysql</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/297/#blogcomment356</link>
<title><![CDATA[[评论] Nginx 0.5.31 + PHP 5.2.4（FastCGI）搭建可承受3万以上并发连接数，胜过Apache 10倍的Web服务器[原创]]]></title> 
<author>菜鸟想飞 &lt;wylf221@yahoo.com.cn&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Tue, 25 Sep 2007 02:27:29 +0000</pubDate> 
<guid>http://zyan.cc/post/297/#blogcomment356</guid> 
<description>
<![CDATA[ 
	张老师。中秋节快了啊！<br/>今天公司发福利了吧！<br/>我看看你最近好像好忙啊！<br/>上次老师说把你的（朝花）的那个程序发给小第学习的！记得有空发给我<br/>邮箱：wylf221@yahoo.com.cn
]]>
</description>
</item><item>
<link>http://zyan.cc/post/297/#blogcomment363</link>
<title><![CDATA[[评论] Nginx 0.5.31 + PHP 5.2.4（FastCGI）搭建可承受3万以上并发连接数，胜过Apache 10倍的Web服务器[原创]]]></title> 
<author>小船 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sun, 30 Sep 2007 02:21:09 +0000</pubDate> 
<guid>http://zyan.cc/post/297/#blogcomment363</guid> 
<description>
<![CDATA[ 
	张老师：您好<br/> &nbsp; &nbsp;如果PHP是用不是编译方式安装，而是使用rpm安装的话，需要如何配置php或者nginx才能<br/>使nginx支持php<br/> &nbsp; &nbsp;另外，nginx配置文件中如何增加alias，最多可以支持多少个alias。<br/>谢谢
]]>
</description>
</item><item>
<link>http://zyan.cc/post/297/#blogcomment364</link>
<title><![CDATA[[评论] Nginx 0.5.31 + PHP 5.2.4（FastCGI）搭建可承受3万以上并发连接数，胜过Apache 10倍的Web服务器[原创]]]></title> 
<author>轻 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sun, 30 Sep 2007 03:07:07 +0000</pubDate> 
<guid>http://zyan.cc/post/297/#blogcomment364</guid> 
<description>
<![CDATA[ 
	张老师 您好<br/><br/>按照您的配置，如果我指定<br/>root /usr/local/www;<br/>index index.php;<br/>的话那么在访问/时访问到的是index.php页面，这是对的。<br/>现在有这样的/usr/local/www/admin目录，但是如果直接用/admin/index.php访问的话会显示 403 请问这个怎么解决？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/297/#blogcomment365</link>
<title><![CDATA[[评论] Nginx 0.5.31 + PHP 5.2.4（FastCGI）搭建可承受3万以上并发连接数，胜过Apache 10倍的Web服务器[原创]]]></title> 
<author>eric &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sun, 30 Sep 2007 05:51:44 +0000</pubDate> 
<guid>http://zyan.cc/post/297/#blogcomment365</guid> 
<description>
<![CDATA[ 
	请教一下，日志文件如何过滤jpg、css文件设置，谢谢。
]]>
</description>
</item><item>
<link>http://zyan.cc/post/297/#blogcomment377</link>
<title><![CDATA[[评论] Nginx 0.5.31 + PHP 5.2.4（FastCGI）搭建可承受3万以上并发连接数，胜过Apache 10倍的Web服务器[原创]]]></title> 
<author>hoosir &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 06 Oct 2007 03:17:35 +0000</pubDate> 
<guid>http://zyan.cc/post/297/#blogcomment377</guid> 
<description>
<![CDATA[ 
	对于运算量很大的php页面，在大负载下，表现稳定么？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/297/#blogcomment393</link>
<title><![CDATA[[评论] Nginx 0.5.31 + PHP 5.2.4（FastCGI）搭建可承受3万以上并发连接数，胜过Apache 10倍的Web服务器[原创]]]></title> 
<author>小船 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 12 Oct 2007 08:45:15 +0000</pubDate> 
<guid>http://zyan.cc/post/297/#blogcomment393</guid> 
<description>
<![CDATA[ 
	张老师：<br/>我设置了alias<br/>location /my/<br/>&#123;<br/> &nbsp; &nbsp; &nbsp;alias /var/www/my/;<br/>&#125;<br/>/var/www/my/目录下的html文件都是可以运行的，但是php文件却无法找到，我的其他配置文件就是按照您的文章写的。<br/><br/>这是什么原因呢？急切等待您的回复，谢谢
]]>
</description>
</item><item>
<link>http://zyan.cc/post/297/#blogcomment404</link>
<title><![CDATA[[评论] Nginx 0.5.31 + PHP 5.2.4（FastCGI）搭建可承受3万以上并发连接数，胜过Apache 10倍的Web服务器[原创]]]></title> 
<author>CodeAll &lt;codeallcn@gmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 18 Oct 2007 04:53:09 +0000</pubDate> 
<guid>http://zyan.cc/post/297/#blogcomment404</guid> 
<description>
<![CDATA[ 
	诧异一下<br/>250个fcgi进程怎么是并发3w？<br/>是一秒处理3w？<br/>netstat列出来的是内核的队列，不是并发啊
]]>
</description>
</item><item>
<link>http://zyan.cc/post/297/#blogcomment437</link>
<title><![CDATA[[评论] Nginx 0.5.31 + PHP 5.2.4（FastCGI）搭建可承受3万以上并发连接数，胜过Apache 10倍的Web服务器[原创]]]></title> 
<author>煤块 &lt;m1391@126.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 02 Nov 2007 04:17:07 +0000</pubDate> 
<guid>http://zyan.cc/post/297/#blogcomment437</guid> 
<description>
<![CDATA[ 
	我按说明 安装玩 php &nbsp;在xxxx/php/bin/下面没有php-cgi &nbsp;只有php这样的执行文件。<br/>请教 哪安装出的问题
]]>
</description>
</item><item>
<link>http://zyan.cc/post/297/#blogcomment441</link>
<title><![CDATA[[评论] Nginx 0.5.31 + PHP 5.2.4（FastCGI）搭建可承受3万以上并发连接数，胜过Apache 10倍的Web服务器[原创]]]></title> 
<author>蓝色疾风 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 03 Nov 2007 07:30:25 +0000</pubDate> 
<guid>http://zyan.cc/post/297/#blogcomment441</guid> 
<description>
<![CDATA[ 
	张老师，感觉你能介绍如此好的一款软件，谢谢！<br/>有个疑问，基于你的这个架构的服务器对动态php程序的执行效率上和apache相比有多大差别呢？你所说的10倍于apache的速度是不是指的是对静态文件的处理效率上呀。
]]>
</description>
</item><item>
<link>http://zyan.cc/post/297/#blogcomment443</link>
<title><![CDATA[[评论] Nginx 0.5.31 + PHP 5.2.4（FastCGI）搭建可承受3万以上并发连接数，胜过Apache 10倍的Web服务器[原创]]]></title> 
<author>五彩阁 &lt;wetr@wer.cn&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 03 Nov 2007 20:32:18 +0000</pubDate> 
<guid>http://zyan.cc/post/297/#blogcomment443</guid> 
<description>
<![CDATA[ 
	请问哪里有下载？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/297/#blogcomment537</link>
<title><![CDATA[[评论] Nginx 0.5.31 + PHP 5.2.4（FastCGI）搭建可承受3万以上并发连接数，胜过Apache 10倍的Web服务器[原创]]]></title> 
<author>左手琴 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 27 Dec 2007 05:32:35 +0000</pubDate> 
<guid>http://zyan.cc/post/297/#blogcomment537</guid> 
<description>
<![CDATA[ 
	请教一下，我在安装库文件的时候，到了这步：<br/>tar zxvf jpegsrc.v6b.tar.gz<br/>cd jpeg-6b/<br/>./configure --enable-static --enable-shared<br/>make &amp;&amp; make install<br/>cd ../<br/>在make &amp;&amp; make install 时报错：./libtool --mode=compile gcc -O2 &nbsp;-I. -c ./jcapimin.c<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; make: ./libtool: Command not found<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; make: *** [jcapimin.lo] Error 127<br/><br/>这是什么原因呢，麻烦您帮我看一下，不胜感激了！
]]>
</description>
</item><item>
<link>http://zyan.cc/post/297/#blogcomment570</link>
<title><![CDATA[[评论] Nginx 0.5.31 + PHP 5.2.4（FastCGI）搭建可承受3万以上并发连接数，胜过Apache 10倍的Web服务器[原创]]]></title> 
<author>codeall &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Tue, 08 Jan 2008 04:24:33 +0000</pubDate> 
<guid>http://zyan.cc/post/297/#blogcomment570</guid> 
<description>
<![CDATA[ 
	fcgi是同步请求，350进程就是350并发，别的都在等。
]]>
</description>
</item><item>
<link>http://zyan.cc/post/297/#blogcomment634</link>
<title><![CDATA[[评论] Nginx 0.5.31 + PHP 5.2.4（FastCGI）搭建可承受3万以上并发连接数，胜过Apache 10倍的Web服务器[原创]]]></title> 
<author>kk &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Tue, 29 Jan 2008 21:47:29 +0000</pubDate> 
<guid>http://zyan.cc/post/297/#blogcomment634</guid> 
<description>
<![CDATA[ 
	<br/>127.0.0.1/index.php 结果是No input file specified.～
]]>
</description>
</item><item>
<link>http://zyan.cc/post/297/#blogcomment1018</link>
<title><![CDATA[[评论] Nginx 0.5.31 + PHP 5.2.4（FastCGI）搭建可承受3万以上并发连接数，胜过Apache 10倍的Web服务器[原创]]]></title> 
<author>kingta &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sun, 04 May 2008 12:35:17 +0000</pubDate> 
<guid>http://zyan.cc/post/297/#blogcomment1018</guid> 
<description>
<![CDATA[ 
	cv
]]>
</description>
</item><item>
<link>http://zyan.cc/post/297/#blogcomment1176</link>
<title><![CDATA[[评论] Nginx 0.5.31 + PHP 5.2.4（FastCGI）搭建可承受3万以上并发连接数，胜过Apache 10倍的Web服务器[原创]]]></title> 
<author>大飞 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 12 Jun 2008 11:40:30 +0000</pubDate> 
<guid>http://zyan.cc/post/297/#blogcomment1176</guid> 
<description>
<![CDATA[ 
	承受不等于高效。。。。。 另外机器配置是问题，系统微调也是个问题
]]>
</description>
</item>
</channel>
</rss>