[文章作者:张宴 本文版本:v1.1 最后修改:2007.07.27 转载请注明出处:http://blog.zyan.cc]

  这两天搭建了一组Apache服务器,每台服务器4G内存,采用的是prefork模式,一开始设置的连接数太少了,需要较长的时间去响应用户的请求,后来修改了一下Apache 2.0.59的配置文件httpd.conf:
引用
# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves

StartServers         10
MinSpareServers      10
MaxSpareServers      15
ServerLimit          2000
MaxClients           2000
MaxRequestsPerChild  10000



  查看httpd进程数(即prefork模式下Apache能够处理的并发请求数):
  Linux命令:
引用
ps -ef | grep httpd | wc -l

  返回结果示例:
  1388
  表示Apache能够处理1388个并发请求,这个值Apache可根据负载情况自动调整,我这组服务器中每台的峰值曾达到过2002。


  查看Apache的并发请求数及其TCP连接状态:
  Linux命令:
引用
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'

  (这条语句是从技术总监王老大那儿获得的,非常不错)
  返回结果示例:
  LAST_ACK 5
  SYN_RECV 30
  ESTABLISHED 1597
  FIN_WAIT1 51
  FIN_WAIT2 504
  TIME_WAIT 1057
  其中的SYN_RECV表示正在等待处理的请求数;ESTABLISHED表示正常数据传输状态;TIME_WAIT表示处理完毕,等待超时结束的请求数。


  关于TCP状态的变迁,可以从下图形象地看出:
  点击在新窗口中浏览此图片  
  状态:描述
  CLOSED:无连接是活动的或正在进行
  LISTEN:服务器在等待进入呼叫
  SYN_RECV:一个连接请求已经到达,等待确认
  SYN_SENT:应用已经开始,打开一个连接
  ESTABLISHED:正常数据传输状态
  FIN_WAIT1:应用说它已经完成
  FIN_WAIT2:另一边已同意释放
  ITMED_WAIT:等待所有分组死掉
  CLOSING:两边同时尝试关闭
  TIME_WAIT:另一边已初始化一个释放
  LAST_ACK:等待所有分组死掉


Tags: , ,



技术大类 » Web服务器 | 评论(67) | 引用(0) | 阅读(138619)
shz Email
2022-8-27 22:22
I was taking a gander at some of your posts on this site and I consider this site is truly informational! Keep setting up..  How To Make $500 A Day (Complete Guide)
shzz Email
2022-8-27 22:22
Nice blog. Found this while searching through  Vodyssey
shzz Email
2022-8-27 22:25
I feel a lot more people need to read this, very good info! .  Vodyssey
shz Email
2022-8-27 22:26
A great website with interesting and unique material what else would you need.  Rental Arbitrage
shz Email
2022-8-27 22:29
I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy.  Rental Arbitrage
zeldae Email Homepage
2023-2-16 11:10
I'd say that someone has to help to make really posts. I've only 2048 recently visited your website, so how are things going so far? I was astounded by the research you conducted for this particular post.
Lucky cola
2024-2-7 13:50
Experience the thrill of victory in every game.  Lucky cola
分页: 4/4 第一页 上页 1 2 3 4 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]