这两天搭建了一组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 100 #这个值不宜过大,防恶意访问
查看httpd进程数(即prefork模式下Apache能够处理的并发请求数):
引用
ps -ef | grep httpd | wc -l
返回结果示例: 实时查看apache的并发数: watch -n 1 -d “pgrep httpd|wc -l”
查看Apache的并发请求数及其TCP连接状态:
引用
netstat -n | awk ‘/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}’
(这条语句是从新浪互动社区事业部技术总监王老大那儿获得的,非常不错) |