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

Analysis of nginx working process

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces the relevant knowledge of "nginx work process Analysis". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Preface

One day, I received a report from a business colleague that the overtime rate of some business was too high. I tried to query the problem and eventually located nginx to reverse proxy some requests to the wrong path, resulting in a timeout.

Problem tracking

I'm going to track the problem from the following clues:

Reverse proxy to the wrong path, this wrong path is what business was done before.

Whether the configuration of reverse proxy is correct

Whether the nginx configuration takes effect correctly

1. Wrong path

The server that this path points to is the load of the previous business, and it was taken off the shelf because of the comparison of this machine. There is no relevant business program on this server. If there is a real-time request to reverse proxy to this machine, the request fails because the server does not deploy the relevant business program.

two。 Whether the configuration of reverse proxy is correct

We looked at the configuration related to upstream and it is true that there is no configuration forwarded to this old machine.

Whether the 3.nginx configuration takes effect correctly

The commands used are:

Nginx-t

Nginx-s reload

First check that the configuration is correct, and then reload.

What the reload command of nginx does.

Refer to the official documentation

Http://nginx.org/en/docs/beginners_guide.html

Once the master process receives a signal that it needs to reload the configuration file, it checks whether the syntax in the new configuration file is correct and tries to apply the configuration. If successful, the master process starts the new worker process and sends a shutdown signal to the old worker process, requesting to shut down the old worker thread. Otherwise, the master process rolls back to the configuration state before the change and continues to use the old configuration file. The old worker thread, when it receives a signal that needs to be closed, stops receiving a new connection and continues to serve the current request until all of them are processed. Finally, the old worker thread exits.

Recall the error: nginx reverse proxies some requests to the wrong path, resulting in a timeout

There are some request reverse proxies to the wrong path, but most of the requested reverse proxies are correct. Whether some worker processes use the current configuration file, while others use the old configuration file. The worker process of those obsolete configuration files will request a reverse proxy to the wrong path.

In fact, it is the only way to test the truth. We log in to the server to query the work progress under the nginx:

Nginxbug1.png

Nginxbug3.png

It was found that there was a work process that was created in 2018, which was obviously problematic. Under nginx master with a pid of 36766, there is a pid worker process for 30284 that was created in 2018.

This is the end of the content of nginx work process Analysis. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Internet Technology

Wechat

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

12
Report