能够单首创建一个虚拟主机来配置 Nginx 状态信息功能html
[root@localhost conf]# vim vhosts/status.abc.conf
server {
listen 80;
server_name status.abc.com;
location / {
stub_status on; # 打开状态信息开关
access_log off;
allow 192.168.153.0/24 # 设置容许访问的 IP 段
deny all; # 设置禁止访问的 IP 段,all 表明除了容许的 IP 之外的全部 IP 都拒绝访问
}
}
使用 ab 压力测试工具模拟用户并发访问网站:nginx
yum -y install httpd-tools
ab -c5000 -n50000 http://www.abc.com/
修改客户端 hosts解析文件,在模拟访问网站的同时访问 http://status.abc.com/vim
Active connections: 1005 server accepts handled requests 152111 152111 149869 Reading: 0 Writing: 1 Waiting: 1004
数值说明:并发
请求丢失数 = accepts - server,能够看出本次状态显示没有丢失请求
在开启 keep-alive 的状况下,Waiting = Active connections - (Reading + Writing)工具