1、启用nginx status配置
在默认主机里面加上location或者你希望能访问到的主机里面。
vim /etc/nginx/nginx.conf # 编辑文件 server { listen *:80 default_server; server_name www.oldtom.cc; location /ngx_status { stub_status on; access_log off; #allow 127.0.0.1; #deny all; } }
2、重启nginx
nginx -s reload
3、打开status页面
http://www.oldtom.cc/ngx_status
# 网页输出结果 Active connections: 2 server accepts handled requests 20 20 110 Reading: 0 Writing: 1 Waiting: 1
返回各数据项说明:
Active connections: 当前nginx正在处理的活动连接数.
Server accepts handled requests request_time: nginx总共处理了20个连接,成功创建20握手(证明中间没有失败的),总共处理了110个请求。
Reading: nginx读取到客户端的Header信息数.
Writing: nginx返回给客户端的Header信息数.
Waiting: 开启keep-alive的情况下,这个值等于 active – (reading + writing),意思就是nginx已经处理完成,正在等候下一次请求指令的驻留连接。
所以,在访问效率高,请求很快被处理完毕的情况下,Waiting数比较多是正常的.如果reading + writing数较多,则说明并发访问量非常大,正在处理过程中。