Full Stack LAMP - MEAN Developer, Python developer. Certified Azure Developer. Freelance programmer/consultant/trainer.

Nginx: worker_connections are not enough

You have to increase the number of worker_connections to fix this issue. You can also increase the number of worker_processes(default = 1), so the total amount of connections your server can handle would be worker_processes * worker_connections

/etc/nginx/nginx.conf

events {
  worker_connections  4096;  ## Default: 1024
}

http {
  include    conf/mime.types;
  .....
}
  • Worker processes:
    • Nginx worker process that handles the incoming request.
    • Set this to worker_process auto; to automatically adjust the number of Nginx worker processes based on available cores.
    • This can go beyond the available cores if you have IO access.
  • Worker connections:
    • Each worker process can open a by default 512 connections.
    • You can change this limit by worker_connections <no>.
    • You can set this to the max limit ulimit -n.

The number of connections is limited by the maximum number of open files (RLIMIT_NOFILE) on your system

Leave a Reply