[Nginx] Concurrent Configuration

 

Configuration parameter: worker_connections, the default maximum concurrent number is 1024

The larger the value is, the larger the number of concurrency is. Of course, you must decide according to your own actual situation, and you can't set it too big, and you can't let your CPU run at 100%.

 

Therefore, when you modify and increase the worker_connections value in the configuration file, and then restart nginx, you will find in the log that the warn warning we mentioned earlier probably means: 20,000 concurrent connections have exceeded open Resource limit for files: 1024! In this case, we need to modify the configuration file and add a line to lift this limit, which is like the ServerLimit in apache.

 

Open the configuration file and add this line above the "event" line:

 

worker_rlimit_nofile   xxxxx;          

####Specifies the value for maximum file descriptors that can be opened by this process.

 

Note: After setting this, when you modify the value of worker_connections, you cannot exceed the value of worker_rlimit_nofile, otherwise there will be the previous warn prompt.

 

Save the configuration file, exit and restart nginx.

 

 

If the worker_connections value setting in nginx is 1024 and the worker_processes value setting is 4, according to the theoretical calculation formula of the maximum number of connections in reverse proxy mode:

max connections = worker_processes * worker_connections/4

 

Looking at the relevant information, the recommended value of worker_connections in the production environment is preferably more than 9000. It is planned to set one nginx to 10240 and observe it for a while.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326488819&siteId=291194637