Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the worker connections problem in Nginx

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to solve the worker connections problem in Nginx, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

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

After the original installation of nginx, the default maximum number of concurrency is 1024, if the number of visits to your website is too large, has far exceeded the concurrent number of 1024, then you have to modify the value of worker_connecions, the larger the value, the greater the number of concurrency. Of course, you must decide according to your own actual situation, and you can't set it too big to let your CPU run at 100%.

So, when you modify and increase the value of worker_ connections in the configuration file, and then restart nginx, you will find in the log that the warn warning we mentioned earlier roughly means that 20000 concurrent connections have exceeded the resource limit for opening files: 1024! In this case, we need to modify the configuration file and add a line to remove 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: when this is set, you cannot change the value of worker_ connections beyond this value of worker_rlimit_nofile, otherwise there will be the previous warn prompt.

Save the configuration file and exit restart nginx.

If the worker_connections value setting in nginx is 1024 and the workerplate value setting is 4, the theoretical formula for calculating the maximum number of connections in reverse proxy mode is as follows:

Maximum number of connections = worker_processes * worker_connections/4

Check the relevant information, the recommended value of worker_connections in the production environment is better than 9000, plan to set a nginx to 10240, and then observe for a period of time.

Thank you for reading this article carefully. I hope the article "how to solve the worker connections problem in Nginx" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report