Hardeep Mehta
Hardeep Mehta

Reputation: 489

How to get current worker connections being used by nginx?

Nginx.conf, looks like this

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

The command ulimit -n gives the number of worker connections available, I want the number which is currently being used by nginx.

Upvotes: 9

Views: 17326

Answers (2)

Hasan Ali Haolader
Hasan Ali Haolader

Reputation: 67

To check all connection

sudo netstat -tupn

To check all established connection

sudo netstat -tupn | grep ESTABLISHED

For count all established connection

sudo netstat -tupn | grep ESTABLISHED | wc -l

Check wait connection to use WAIT instead of ESTABLISHED

Upvotes: 0

Tan Hong Tat
Tan Hong Tat

Reputation: 6864

The ngx_http_stub_status_module module provides access to basic status information.

location /basic_status {
    stub_status;
}

This configuration creates a simple web page with basic status data which may look like as follows:

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

Source: https://nginx.org/en/docs/http/ngx_http_stub_status_module.html

Upvotes: 15

Related Questions