In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
A detailed introduction to reverse proxy caching
Traditional proxy: the user is hidden behind the proxy server. The proxy server works at the application layer and forwards only the data of the protocols it supports.
Reverse proxy (Reverse Proxy): this mechanism is that the Web server is hidden behind the proxy server, and the server that implements this mechanism is called reverse proxy server (Reverse Proxy Server). At this point, the Web server becomes the back-end server, and the reverse proxy server is called the front-end server.
One of the purposes of introducing a reverse proxy server is cache-based acceleration. We can cache the content on the reverse proxy server, and all caching mechanisms are still implemented using the HTTP/1.1 protocol.
The reverse proxy server does not use caching:
Nginx can be used as a reverse proxy server for Apache. When the reverse proxy server does not use caching, the throughput will decrease, because the request that originally went directly to Web is now routed, and the processing time is bound to increase.
The Web server can be separated from the application server, where the former handles some static content and acts as a reverse proxy, while the latter handles dynamic content.
Reverse proxy server (RPS) uses caching:
As a RPS, Varnish can provide better caching function. If the cached content works, the server appears as the back-end server in the Http response header, but the Via tag indicates the source of the data.
RPS can modify the Http header information that flows through it to determine what can and cannot be cached. Browsers and Web servers communicate their requirements to RPS,RPS for coordination caching through Http.
Varnish modifies the cache rules through configuration files, using the VCL language. It also provides the ability to force cache clearances. Varnish provides a monitor program Varnishstat to monitor the cache hit ratio.
Ideal technical model for cache hit ratio and back-end throughput:
Actual throughput: refers to the actual throughput of the reverse proxy server when processing user requests.
Back-end throughput: the throughput of the back-end Web server when processing requests from the reverse proxy server.
Number of active content: the number of times the reverse proxy server requests content from the back-end server during the average cache validity period.
Cache loss rate = (number of active content / (actual throughput × average cache validity) × 100%
Cache hit ratio = 1-cache loss rate
Backend throughput = active content / average cache validity period
Cache hit rate = (1-(backend throughput / actual throughput) × 100%
Backend throughput = (1-cache hit rate) × actual throughput
Conclusion:
1. When the number of active content and the average cache validity are constant, the cache hit rate is proportional to the actual throughput.
two。 When the actual throughput rate and the average cache validity are constant, the cache hit rate is inversely proportional to the number of active content.
3. When the number of active content and the actual throughput are constant, the cache hit rate is proportional to the average cache validity period.
4. When the number of active content is constant, the back-end throughput is inversely proportional to the average cache validity.
5. When the average cache validity period is constant, the back-end throughput is proportional to the number of active content.
6. Changes in cache hit rates do not necessarily affect back-end throughput.
7. Changes in back-end throughput do not necessarily affect cache hit rates.
Thus, it is a misconception that the higher the cache hit rate, the less the back-end server workload.
ESI (Edge Side Includes)
ESI is similar to SSI in that you can embed sub-pages in a page. Unlike SSI, SSI assembles content on the Web server side, and ESI assembles content on a Http proxy server, including reverse proxies.
Varnish supports ESI, so Varnish supports local caching of web pages and enables local updates of dynamic content. AJAX has a similar feature (it supports asynchronous requests for local content).
Pass through the agent:
As an intermediary between the user and the back-end Web server, the reverse proxy server only forwards the user's Http request to the back-end server, but sometimes some information of the user is not in the Http request, such as the user's IP address and the TCP port on which the request is sent, which is not visible to the back-end Web server, so it is necessary to find a way to make this information.
"through" reverse proxy server.
Method: let the reverse proxy request the back-end server with additional Http header information (achieved by configuring the reverse proxy server). Similarly, if the back-end server wants to tell the browser some additional information, it can also carry a custom message "through" the reverse proxy in the Http response header.
The advantages of Nginx and Lighttpd are mainly reflected in the network IO model.
Nginx uses the epoll model to provide high throughput in the case of a large number of concurrent users.
The problem with Ajax is that the local content should keep the same top-level domain as the host where the parent page is located.
Factors that affect cache hit rate: cache expiration time, cache space is not large enough to be swapped out, cache granularity, architecture design.
What are the factors that affect the processing power of Web servers? (chapter on server concurrent processing power)
If you have any questions, please leave a message or go to the community to exchange and discuss, thank you for reading, hope to help you, thank you for your support!
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.