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

A case study of nginx read timeout

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

Share

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

This article mainly introduces the "case study of nginx read timeout". In daily operation, I believe many people have doubts about the case analysis of nginx read timeout. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "nginx read timeout case analysis". Next, please follow the editor to study!

Problem description

Our business output is similar to sesame score, and the deployment architecture is the access layer-"business logic -" scoring service layer. Each layer corresponds to a physical process. It is the scoring service layer that really calculates the score. I would like to query the questions in turn according to the following steps: 1 whether the scoring service has reached the performance launch 2 whether the business logic layer access scoring service conditions are harsh

1 whether the scoring service achieves the performance online

I made a statistics on the trading time of the scoring service, the sample size is 95w:

Average response time 301ms

Standard check 238ms

Minimum time consuming 6ms

The first 25% time-consuming 176ms

The first 75% time-consuming 372ms

The first 90% time-consuming 511ms

The first 99% time-consuming 993ms

Maximum time consuming 15000ms

26 more than 10 seconds

There are no failed transactions, but there are longer transactions, and the scoring service does not reach the upper limit.

Why do some transactions take more than 10 seconds? From a business point of view, someone may have a large amount of data and take up a large amount of io and cpu.

2 whether the service conditions of business logic layer access scoring are harsh

The business logic accesses the scoring service through nginx as a reverse proxy, and the final request is loaded on multiple servers. We looked at the nginx access log at that time and found that it was 499%.

Nginx 499 CLIENT CLOSED REQUEST

A non-standard status code introduced by nginx to indicate that the client closes the connection when the nginx is processing the request

I inquired about the time it takes for the business logic layer to access the scoring service: connect for 2 seconds and read for 10 seconds. The problem was found that when the scoring service load is high, the processing time of some requests may exceed 10 seconds. Because the read timeout set by the business logic layer is 10s, the connection is actively disconnected.

Scheme

In scheme 1, the reading time of the business logic layer accessing the scoring service and the access layer accessing the business logic layer is greater than the maximum time for the scoring service to process the request normally. Disadvantages: this is a temporary cure, the customer's experience is relatively poor.

Plan 2, solve the problem in the scoring service layer, find out the code location that consumes a lot of time, and consider optimization. Disadvantages, relatively long cycle

Plan 3, horizontally expand the scoring service layer. Disadvantages: consuming machine resources (not having that much money to buy machines)

Will the potential problem increase the read time of the client and affect the throughput of the overall system?

We have counted the time-related indicators of the scoring service, and 99% of the transactions can be completed in 993ms, that is, within 1s. The really time-consuming transactions are very few, so it has little impact on the overall system throughput.

At this point, the study on the "case study of nginx read timeout" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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