nginx server config for high availability

Using the following setup my server is able to handle lots of (virtual) concurrent users.

worker_processes 4;
worker_connections 8192;
worker_rlimit_nofile 40000;

Here’s how I calculated these values on a 8 GB RAM / 4 CPUs droplet:

worker_processes= 1x for each CPU worker_connections= 2048 x 4 CPUs worker_rlimit_nofile = roughly 10.000 per core (my wild guess)

  1. How can I improve my setup/calculation above?
  2. Does anyone have working numbers for the largest droplet 64 GB / 20 CPU ?

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Those settings look sane to me and seem to follow best practices. This blog post has been helpful to me in understanding these setting:

Workers are not multi-threaded so they do not spread the per-connection across CPU cores. Thus it makes sense for us to run multiple workers, usually 1 worker per CPU core. For most work loads anything above 2-4 workers is overkill as nginx will hit other bottlenecks before the CPU becomes an issue and usually you’ll just have idle processes.

For more information on optimizing Nginx, check out: