Tuning nginx worker_process to obtain 100k hits per min

Nginx

Nginx Problem Overview


We have a server that is serving one html file.

Right now the server has 2 CPUs and 2GB of ram. From blitz.io, we are getting about 12k connections per minute and anywhere from 200 timeouts in that 60 seconds with 250 concurrent connections each second.

worker_processes  2;

events {
 worker_connections 1024;
}

If I increase the timeout, the response time starts creeping up beyond a second.

What else can I do to squeeze more juice out of this?

Nginx Solutions


Solution 1 - Nginx

Config file:

worker_processes  4;  # 2 * Number of CPUs

events {
    worker_connections  19000;  # It's the key to high performance - have a lot of connections available
}

worker_rlimit_nofile    20000;  # Each connection needs a filehandle (or 2 if you are proxying)


# Total amount of users you can serve = worker_processes * worker_connections

more info: Optimizing nginx for high traffic loads

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionablemikeView Question on Stackoverflow
Solution 1 - NginxBulatView Answer on Stackoverflow