Home  >  Article  >  Operation and Maintenance  >  Detailed explanation of worker connections issues in Nginx

Detailed explanation of worker connections issues in Nginx

Y2J
Y2JOriginal
2017-05-24 14:08:573076browse

This article mainly introduces the solution to the problem of worker connections in Nginx, which has certain reference value. Interested friends can refer to it

View the log, there is a [warn]: 3660#0: 20000 worker_connections are more than open file resource limit: 1024 !!

OriginalInstallation After nginx is installed, the default maximum number of concurrency is 1024. If your website has too many visits and has far exceeded the number of concurrency of 1024, then you need to modify the value of worker_connecions. The larger the value, the greater the number of concurrencies. Just big. Of course, you must decide according to your own actual situation, and you cannot set it too large to allow your CPU to run at 100%.

So, when you modify and increase the worker_connections value in the configuration file, and then restart nginx, you will find in the log the warning prompt we talked about earlier, The general meaning is: 20,000 concurrent connections have exceeded the resource limit of open files: 1024! In this case, we need to modify the configuration file and add a line to lift this restriction, which is like 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 worker_connections value, you cannot exceed the value of worker_rlimit_nofile, otherwise there will be another problem. The warn prompt.

Save the configuration file, Exit

Restart nginx.

If the worker_connections value setting in nginx is 1024 and the worker_processes value setting is 4, press the reverse Proxy mode

Theoretical calculation formula for the maximum number of connections under:

Maximum number of connections = worker_processes * worker_connections/4

Check the relevant information. In the production environment, the recommended value of worker_connections is preferably more than 9000. We plan to set an nginx to 10240 and observe for a while.


【Related Recommendations】

1. Linux Free Video Tutorial

2. Boolean Education Linux Optimization Video Tutorial

3. Detailed example of using yum to install Nginx in Linux

4. Teach you how to install Nginx server in Linux

5. Detailed introduction to the wget command of Linux

###

The above is the detailed content of Detailed explanation of worker connections issues in Nginx. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn