By sugarhill
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)
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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:
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.