日期:2014-05-16 浏览次数:20918 次
查看Apache并发请求数及其TCP连接状态
一、apache启用参数www.zongguofeng.cn
apache配置文件中,配置文件httpd.conf中启用
#Include conf/extra/httpd-mpm.conf
也就是去掉#号即保存
二、详细配置文件修改
然后修改conf/extra/httpd-mpm.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能够处理的并发请求数):
[root@linuxzgf ~]# ps -ef | grep httpd | wc -l
返回结果示例:
800
表示Apache能够处理800个并发请求,这个值Apache可根据负载情况自动调整
四、查看Apache的并发请求数及其TCP连接状态:
[root@linuxzgf ~]# netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
返回结果如下:
TIME_WAIT 869
CLOSE_WAIT 5
FIN_WAIT1 39
ESTABLISHED 105
FIN_WAIT2 94
SYN_RECV 25
LAST_ACK 3
意思解释:
SYN_RECV表示正在等待处理的请求数;
ESTABLISHED表示正常数据传输状态;
TIME_WAIT表示处理完毕,等待超时结束的请求数。
注释:此图与解释来至与张宴博客
关于TCP状态的变迁,可以从下图形象地看出:
表示处理完毕,等待超时结束的请求数。