能夠單首創建一個虛擬主機來配置 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)工具