【问题标题】:How to get current worker connections being used by nginx?如何获取 nginx 正在使用的当前工作连接?
【发布时间】:2021-04-06 09:27:58
【问题描述】:

Nginx.conf,长这样

user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
        worker_connections 768;
        # multi_accept on;
}

ulimit -n 命令给出了可用的工作连接数,我想要 nginx 当前正在使用的数。

【问题讨论】:

    标签: ubuntu nginx


    【解决方案1】:

    ngx_http_stub_status_module 模块提供对基本状态信息的访问。

    location /basic_status {
        stub_status;
    }
    

    此配置创建一个包含基本状态数据的简单网页,如下所示:

    Active connections: 291 
    server accepts handled requests
     16630948 16630948 31070465 
    Reading: 6 Writing: 179 Waiting: 106 
    

    来源:https://nginx.org/en/docs/http/ngx_http_stub_status_module.html

    【讨论】:

    • 有没有办法从终端获取这些信息,而不是让 nginx 服务一个页面?
    • 我不知道另一种获取它的方法。您可以从终端 wget/curl localhost/basic_status
    • 这没有回答问题。有没有办法准确地找到当前正在使用的工作人员(或工作人员连接)的数量?
    猜你喜欢
    • 2017-08-17
    • 1970-01-01
    • 2016-10-01
    • 1970-01-01
    • 2013-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-25
    相关资源
    最近更新 更多