
Worker processes
When we start the NGINX service, we get a master process which we can view using systemctl. This master process then spawns worker processes that are used to serve requests. The default is one worker process.
We can change the no. of worker processes using the worker_processes directive. But more workers do not necessarily mean more performance. Each NGINX process will serve as many requests as the hardware can support.
There are instances where there are benefits in increasing the no. of worker processes. On a multicore CPU, for example. A single NGINX process can only work on one core of a CPU. So say, we have an 8-core CPU. The optimal no. of worker processes would be 8. Do not run more than one process on one core.
You may check the no. of CPU cores in a Linux server using:
nproc
lscpu
Setting the worker_processes directive to auto will auto-increase the no. of processes to match the no. of cores on your server.
worker_processes auto;
No. of connections per worker
events {
worker_connections 1024;
}
The worker_connections directive specifies the maximum number of connections that each worker process can handle. The default value is 512. However, you may want to increase the value of worker_connections if your server is handling a lot of traffic.
For example, if you have a server with 4 GB of RAM, you might want to set worker_connections to 1024. This will allow each worker process to handle up to 1024 connections, which can help to improve performance.
It is important to note that the total number of connections that NGINX can handle is limited by the number of open file descriptors that the system allows. You can check the maximum number of open file descriptors with the following command:
ulimit -n
1024
If the number of open file descriptors is lower than the value of worker_connections, you will need to increase the value of ulimit.
Request Capacity
Total no. of requests that can be served = worker processes * worker connections
This is very important for the performance optimization of NGINX.
Conclusion
By understanding the worker processes and number of connections settings in NGINX, you can optimize your server's performance and ensure that it can handle a large number of concurrent connections.
About the author
I am a DevOps Consultant. 3 years experience with Cloud technologies. 9 years total IT experience in the Linux, Networking and Data Visualization domains. Love listening to music and playing older PC games.
Comments
Join the discussionClear explanation of master vs workers and why worker_connections is not just "max RPS." In reverse-proxy edge roles I size workers to CPU cores (auto is fine) and set worker_connections for concurrent client sockets plus upstream sockets, because each proxied request can hold both sides open under keepalive. Underestimating that number shows up as accept queue growth and intermittent 502s long before CPU saturates.
Ops check after a tune: watch active and waiting connections under load, confirm worker_connections * worker_processes leaves headroom above peak, and keep multi_accept on only when the accept queue actually builds. If waiting climbs while CPU is idle, raise connections or shorten idle keepalive timeouts before adding hardware. Log worker exits and reopen cycles after reload — a sudden drop in worker count after config change usually means a limit was hit, not a traffic cliff.
Configuring NGINX
In this basic level series, I will post best practices to configure the NGINX web server using Linux based instances.




