Monday 16 December 2019

NGINX: worker_connections: Maximum number of connections opened by a worker process


worker_connections directive is used to set the maximum number of simultaneous connections that can be opened by a worker process.

Syntax: worker_connections number;
Default: worker_connections 512;
Context: events

Again this is limited by system resources. You can check how many connections can be opened for a process using 'ulimit -n' command.
$ulimit -n
256
$
$
$ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 256
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1418
virtual memory          (kbytes, -v) unlimited

I can open maximum of 256 connections for a worker process.


Example

events {
   worker_connections 256;
}

nginx.conf
worker_processes auto;

events {
   worker_connections 256; 
}

http {
    include mime.types;

    server {
        listen 9090;

        server_name localhost;

        location = /about{
            return 200 "Hello Welcome to NGINX";
        }

        location = /not_found{
            return 404 "File can't be found";
        }
    }
}





Previous                                                    Next                                                    Home

No comments:

Post a Comment