<?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/269/</link>
<title><![CDATA[查看Apache并发请求数及其TCP连接状态[原创]]]></title> 
<author>张宴 &lt;net@s135.com&gt;</author>
<category><![CDATA[Web服务器]]></category>
<pubDate>Fri, 20 Jul 2007 10:30:29 +0000</pubDate> 
<guid>http://zyan.cc/post/269/</guid> 
<description>
<![CDATA[ 
	　　[文章作者：张宴 本文版本：v1.1 最后修改：2007.07.27 转载请注明出处：<a href="http://blog.zyan.cc" target="_blank">http://blog.zyan.cc</a>]<br/><br/>　　这两天搭建了一组Apache服务器，每台服务器4G内存，采用的是prefork模式，一开始设置的连接数太少了，需要较长的时间去响应用户的请求，后来修改了一下Apache 2.0.59的配置文件httpd.conf：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"># prefork MPM<br/># StartServers: number of server processes to start<br/># MinSpareServers: minimum number of server processes which are kept spare<br/># MaxSpareServers: maximum number of server processes which are kept spare<br/># MaxClients: maximum number of server processes allowed to start<br/># MaxRequestsPerChild: maximum number of requests a server process serves<br/><IfModule prefork.c><br/>StartServers &nbsp; &nbsp; &nbsp; &nbsp; 10<br/>MinSpareServers &nbsp; &nbsp; &nbsp;10<br/>MaxSpareServers &nbsp; &nbsp; &nbsp;15<br/>ServerLimit &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2000<br/>MaxClients &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2000<br/>MaxRequestsPerChild &nbsp;10000<br/></IfModule></div></div><br/><hr/><br/>　　查看httpd进程数（即prefork模式下Apache能够处理的并发请求数）：<br/>　　Linux命令：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">ps -ef &#124; grep httpd &#124; wc -l</div></div><br/>　　返回结果示例：<br/>　　1388<br/>　　表示Apache能够处理1388个并发请求，这个值Apache可根据负载情况自动调整，我这组服务器中每台的峰值曾达到过2002。<br/><hr/><br/>　　查看Apache的并发请求数及其TCP连接状态：<br/>　　Linux命令：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">netstat -n &#124; awk '/^tcp/ &#123;++S[$NF]&#125; END &#123;for(a in S) print a, S[a]&#125;'</div></div><br/>　　（这条语句是从<SCRIPT language=JavaScript>word1 = "新";word2 = "浪";word3 = "互动社";word4 = "区事";word5 = "业部";document.write(word1 + word2 + word3 + word4 + word5);</SCRIPT>技术总监王老大那儿获得的，非常不错）<br/>　　返回结果示例：<br/>　　LAST_ACK 5<br/>　　SYN_RECV 30<br/>　　ESTABLISHED 1597<br/>　　FIN_WAIT1 51<br/>　　FIN_WAIT2 504<br/>　　TIME_WAIT 1057<br/>　　其中的SYN_RECV表示正在等待处理的请求数；ESTABLISHED表示正常数据传输状态；TIME_WAIT表示处理完毕，等待超时结束的请求数。<br/><hr/><br/>　　关于TCP状态的变迁，可以从下图形象地看出：<br/>　　<a href="http://zyan.cc/attachment/200707/tcps.gif" target="_blank"><img src="http://zyan.cc/attachment/200707/tcps.gif" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a>　　<br/>　　状态：描述<br/>　　CLOSED：无连接是活动的或正在进行<br/>　　LISTEN：服务器在等待进入呼叫<br/>　　SYN_RECV：一个连接请求已经到达，等待确认<br/>　　SYN_SENT：应用已经开始，打开一个连接<br/>　　ESTABLISHED：正常数据传输状态<br/>　　FIN_WAIT1：应用说它已经完成<br/>　　FIN_WAIT2：另一边已同意释放<br/>　　ITMED_WAIT：等待所有分组死掉<br/>　　CLOSING：两边同时尝试关闭<br/>　　TIME_WAIT：另一边已初始化一个释放<br/>　　LAST_ACK：等待所有分组死掉<br/><br/>Tags - <a href="http://zyan.cc/tags/linux/" rel="tag">linux</a> , <a href="http://zyan.cc/tags/apache/" rel="tag">apache</a> , <a href="http://zyan.cc/tags/tcp/" rel="tag">tcp</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/269/#blogcomment193</link>
<title><![CDATA[[评论] 查看Apache并发请求数及其TCP连接状态[原创]]]></title> 
<author>追寻 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 20 Jul 2007 11:08:30 +0000</pubDate> 
<guid>http://zyan.cc/post/269/#blogcomment193</guid> 
<description>
<![CDATA[ 
	第一个沙发.
]]>
</description>
</item><item>
<link>http://zyan.cc/post/269/#blogcomment195</link>
<title><![CDATA[[评论] 查看Apache并发请求数及其TCP连接状态[原创]]]></title> 
<author>小学妹 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 20 Jul 2007 12:28:20 +0000</pubDate> 
<guid>http://zyan.cc/post/269/#blogcomment195</guid> 
<description>
<![CDATA[ 
	师兄呀，最近怎么样了？看你博客上都是工作上的事情，怎么好久没有见你提到嫂子呀。嫂子那么漂亮，小心被人家强跑了呀呵呵！
]]>
</description>
</item><item>
<link>http://zyan.cc/post/269/#blogcomment196</link>
<title><![CDATA[[评论] 查看Apache并发请求数及其TCP连接状态[原创]]]></title> 
<author>民大学弟 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 20 Jul 2007 15:32:05 +0000</pubDate> 
<guid>http://zyan.cc/post/269/#blogcomment196</guid> 
<description>
<![CDATA[ 
	wonderful！
]]>
</description>
</item><item>
<link>http://zyan.cc/post/269/#blogcomment197</link>
<title><![CDATA[[评论] 查看Apache并发请求数及其TCP连接状态[原创]]]></title> 
<author>民大学弟 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 20 Jul 2007 15:55:02 +0000</pubDate> 
<guid>http://zyan.cc/post/269/#blogcomment197</guid> 
<description>
<![CDATA[ 
	呵呵，这两天没见你在博客上发有关国足亚洲杯出局的帖子，我想：怪了，难道张宴大哥没看国足同乌兹别克斯坦的比赛么？哦，原来是忙这个……不过话又说回来，忙的时候还是要忙，有球看时还是要看球，毕竟亚洲杯不是天天都有的……呵呵，今天就说到这儿了……好像嫂子今天回来了嘛，呵呵，共度良宵哈……
]]>
</description>
</item><item>
<link>http://zyan.cc/post/269/#blogcomment199</link>
<title><![CDATA[[评论] 查看Apache并发请求数及其TCP连接状态[原创]]]></title> 
<author>Jeffy &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 21 Jul 2007 03:00:16 +0000</pubDate> 
<guid>http://zyan.cc/post/269/#blogcomment199</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item><item>
<link>http://zyan.cc/post/269/#blogcomment200</link>
<title><![CDATA[[评论] 查看Apache并发请求数及其TCP连接状态[原创]]]></title> 
<author>Jeffy &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 21 Jul 2007 03:11:42 +0000</pubDate> 
<guid>http://zyan.cc/post/269/#blogcomment200</guid> 
<description>
<![CDATA[ 
	Jeffy
]]>
</description>
</item><item>
<link>http://zyan.cc/post/269/#blogcomment202</link>
<title><![CDATA[[评论] 查看Apache并发请求数及其TCP连接状态[原创]]]></title> 
<author>民大学弟 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sun, 22 Jul 2007 14:42:45 +0000</pubDate> 
<guid>http://zyan.cc/post/269/#blogcomment202</guid> 
<description>
<![CDATA[ 
	张宴大哥,有个问题想麻烦你一下,下面的css样式表非要编程么,用dreamweaver做不做得出来,怎么做,大概说一下哈<br/>#primary-nav LI.selected UL LI A &#123;<br/> &nbsp;BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 0px; PADDING-LEFT: 2px; FONT-SIZE: 12px; BACKGROUND: url(images/Menu0.jpg) #cccccc; PADDING-BOTTOM: 0px; VERTICAL-ALIGN: middle; WIDTH: 120px; COLOR: #000000; TEXT-INDENT: 24px; PADDING-TOP: 3px; BORDER-BOTTOM: #cccccc 1px solid; HEIGHT: 25px<br/>&#125;<br/>麻烦你了,希望你在有空的时候回答我,没空也就算了……<br/>我的邮箱是be_ok@163.com给你添麻烦了……<br/>还有primary-nav、nav是什么东东，我是外行，别笑话我哈
]]>
</description>
</item><item>
<link>http://zyan.cc/post/269/#blogcomment306</link>
<title><![CDATA[[评论] 查看Apache并发请求数及其TCP连接状态[原创]]]></title> 
<author>laughtiger &lt;yuejinshan2000@163.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 05 Sep 2007 02:25:13 +0000</pubDate> 
<guid>http://zyan.cc/post/269/#blogcomment306</guid> 
<description>
<![CDATA[ 
	您好，请教个问题，我的apache2.0.54+jrun3.1的平台 &nbsp;系统运行一段时间后apache的logs就会出现Terminating 1 threads that failed to exit这个错误提示， 一般都是出现这个错误的时候 apache.exe进程就不释放内存了 越来越大 不释放 这个是什么原因 怎么解决 非常着急 非常感谢。
]]>
</description>
</item><item>
<link>http://zyan.cc/post/269/#blogcomment1040</link>
<title><![CDATA[[评论] 查看Apache并发请求数及其TCP连接状态[原创]]]></title> 
<author>游客 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 09 May 2008 08:20:18 +0000</pubDate> 
<guid>http://zyan.cc/post/269/#blogcomment1040</guid> 
<description>
<![CDATA[ 
	netstat -n &#124; awk &#039;/^tcp/ &#123;++S[$NF]&#125; END &#123;for(a in S) print a, S[a]&#125;&#039; <br/>看不懂 &nbsp;能给解释一下么？<br/>尤其是awk &#039;/^tcp/ &#123;++S[$NF]&#125; END &#123;for(a in S) print a, S[a]&#125;&#039; &nbsp;是什么意思
]]>
</description>
</item><item>
<link>http://zyan.cc/post/269/#blogcomment1310</link>
<title><![CDATA[[评论] 查看Apache并发请求数及其TCP连接状态[原创]]]></title> 
<author>scottjin &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Tue, 08 Jul 2008 10:33:05 +0000</pubDate> 
<guid>http://zyan.cc/post/269/#blogcomment1310</guid> 
<description>
<![CDATA[ 
	NF 是当前记录的字段个数, 使用$NF可以实现每个记录的最后一个字段 就和$6一样
]]>
</description>
</item><item>
<link>http://zyan.cc/post/269/#blogcomment1838</link>
<title><![CDATA[[评论] 查看Apache并发请求数及其TCP连接状态[原创]]]></title> 
<author>xiaoyi &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 31 Oct 2008 04:10:43 +0000</pubDate> 
<guid>http://zyan.cc/post/269/#blogcomment1838</guid> 
<description>
<![CDATA[ 
	张大哥。<br/>我的apche<br/>ServerLimit &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2000<br/>StartServers &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 10<br/>MinSpareServers &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10<br/>MaxSpareServers &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;20 <br/>MaxClients &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1980<br/>MaxRequestsPerChild &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;124<br/>我的配置<br/>ps -ef &#124; grep httpd &#124; wc -l的值到2050 访问就很慢了<br/>怎么调才好些挖<br/><br/>硬件配置都蛮好
]]>
</description>
</item><item>
<link>http://zyan.cc/post/269/#blogcomment2513</link>
<title><![CDATA[[评论] 查看Apache并发请求数及其TCP连接状态[原创]]]></title> 
<author>hey &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 04 Feb 2009 14:59:00 +0000</pubDate> 
<guid>http://zyan.cc/post/269/#blogcomment2513</guid> 
<description>
<![CDATA[ 
	新年好，祝贵站新年人气更旺！也欢迎来我站逛逛！<a href="http://jeeyeelee.com" target="_blank">soittoäänet</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/269/#blogcomment3695</link>
<title><![CDATA[[评论] 查看Apache并发请求数及其TCP连接状态[原创]]]></title> 
<author>myair &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 16 Jul 2009 15:47:23 +0000</pubDate> 
<guid>http://zyan.cc/post/269/#blogcomment3695</guid> 
<description>
<![CDATA[ 
	张哥,请教下:使用netstat -nat&#124;awk &#039;&#123;print awk $NF&#125;&#039;&#124;sort&#124;uniq -c&#124;sort -n命令等到的结果<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 established)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 State<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5 FIN_WAIT1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8 LISTEN<br/>&nbsp;&nbsp;&nbsp;&nbsp; 31 TIME_WAIT<br/>&nbsp;&nbsp;&nbsp;&nbsp;368 FIN_WAIT2<br/>&nbsp;&nbsp;&nbsp;&nbsp;564 ESTABLISHED<br/>&nbsp;&nbsp;16030 CLOSE_WAIT<br/>CLOSE_WAIT是什么状态?我使用的是apache+resin,为什么这个值这么高?
]]>
</description>
</item><item>
<link>http://zyan.cc/post/269/#blogcomment4045</link>
<title><![CDATA[[评论] 查看Apache并发请求数及其TCP连接状态[原创]]]></title> 
<author>ronaldhei &lt;tuk.tuk.ya.tvoi.drug@gmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 16 Sep 2009 02:34:02 +0000</pubDate> 
<guid>http://zyan.cc/post/269/#blogcomment4045</guid> 
<description>
<![CDATA[ 
	&lt;h1&gt; <a href="http://cailis.ifrance.com/cailis-online-.html" target="_blank"> Cailis online </a>&nbsp;&nbsp;&lt;/h1&gt;<br/>&lt;h1&gt; <a href="http://cailis.ifrance.com/cailis.html" target="_blank"> Cailis</a>&nbsp;&nbsp;&lt;/h1&gt;<br/><br/>&lt;h1&gt; <a href="http://cailis.ifrance.com/sitemap.html" target="_blank"> Sitemap of <a href="http://cailis.ifrance.com/" target="_blank">http://cailis.ifrance.com/</a></a>&nbsp;&nbsp;&lt;/h1&gt;<br/>[emot]stupid[/emot]
]]>
</description>
</item><item>
<link>http://zyan.cc/post/269/#blogcomment10089</link>
<title><![CDATA[[评论] 查看Apache并发请求数及其TCP连接状态[原创]]]></title> 
<author>michael &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 10 Oct 2011 03:02:07 +0000</pubDate> 
<guid>http://zyan.cc/post/269/#blogcomment10089</guid> 
<description>
<![CDATA[ 
	ps -ef &#124; grep httpd &#124; wc -l<br/><br/>为什么执行这个命令结果总是1
]]>
</description>
</item>
</channel>
</rss>