In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "how to solve the download failure caused by Nginx Buffer mechanism". In the operation of actual cases, many people will encounter such a dilemma, so 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!
Nginx Buffer mechanism
During the Nginx agent process, there are two connections:
1. Client to Nginx connection 2.Nginx to back-end server connection
The speed of the two connections is inconsistent, which will have a negative impact on the client experience. Nginx alleviates this problem through the Buffer mechanism.
When buffer is enabled, Nginx will temporarily store the back-end response content in memory or disk, and then slowly push the data to the client; if closed, it will be synchronized to the client immediately according to the response content.
Assuming that the client is fast enough, you can turn off buffer and let the data arrive as quickly as possible; if the client is slow, you should keep buffer on, which is conducive to connection reuse between Nginx and the backend (essentially a HTTP head-of-line blocking problem).
Problem with downloading large files
The Nginx Buffer mechanism, which is turned on by default, controls the amount of memory written to it according to the parameters proxy_buffer_size and proxy_buffers. If the response is greater than this buffer size, Nginx continues to write the rest of the response to the disk temporary file through the proxy_max_temp_file_size parameter.
So the question is, what if the response is still large and exceeds the temporary file limit?
Wait! At this point, the socket buffer of Nginx is also in a fully loaded state. Because the client is slow, Nginx does not trigger the read backend operation. There is a high probability that the write timeout of the backend server will be triggered and the close operation will be initiated by the backend.
This is my problem: proxy_max_temp_file_size defaults to 1G, and when the client's network is slow, temporary files are quickly full. At this point, the response from the back end will continue to be received into the socket buffer until the buffer is full. At this point, the server where Nginx is located tells the backend server to stop sending data through the sliding window zero 0 until the backend write timeout is triggered.
When the client's network is fast, temporary files will not be full, or even if they are full, they will soon be consumed, so that the back-end "blocking" will not trigger a timeout for too long.
How to solve?
1. Resize the proxy_max_temp_file_size so that the temporary file is large enough to buffer the entire response and let the data flow on the entire link without blocking the back-end write operation, thus triggering the back-end timeout 2. It is not recommended to turn off Buffer, which will affect the reuse of Nginx-to-backend connections.
This is the end of the content of "how to solve the download failure caused by Nginx Buffer mechanism". Thank you for 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.