All Products
Search
Document Center

:Alibaba Cloud Content Delivery Network cache hit rate is low

Last Updated:Jan 12, 2022

Overview

The cache hit rate displayed in the Alibaba Cloud Content Delivery Network console is not high all the time, and the origin server receives a large number of back-to-origin requests from the Alibaba Cloud Content Delivery Network, which causes a certain load pressure on the origin server. You need to troubleshoot the reason why the cache hit rate is not high.

Background information

If the hit rate is too low, it means that each request of the user will be returned to the source through the Alibaba Cloud Content Delivery Network. The instability of the public network link may cause the acceleration effect to deteriorate instead. How to solve the problem of low hit rate, first, see the following operations to analyze the specific reasons:

View the hit rate and traffic Alibaba Cloud Content Delivery Network the console

  1. The cache hit rate counted by the Alibaba Cloud Content Delivery Network console is only the hit rate of the Alibaba Cloud Content Delivery Network L1 node. The actual cache data of the L2 node is also obtained from the Alibaba Cloud Content Delivery Network node and does not obtain data from the origin server. Therefore, the real Alibaba Cloud Content Delivery Network hit rate is slightly higher than the hit rate displayed in the Alibaba Cloud Content Delivery Network console.
    Description: Alibaba Cloud Content Delivery Network data flows to the client> Alibaba Cloud Content Delivery Network level 1 node> Alibaba Cloud Content Delivery Network level 2 node> origin server.
  2. View the traffic of the submitted Alibaba Cloud Content Delivery Network accelerated domain name. When the traffic of the accelerated domain name is not high, even if there are not many URLs in the MISS state, the statistical calculation of the hit rate is greatly affected. For example, a Alibaba Cloud Content Delivery Network accelerated domain name provides a total of 10 accessible URLs, one of which has no-cache set on the URL source station, resulting in no caching. If all other URL accesses are hit, the hit rate is only 90%.
    Note: The traffic bandwidth of the Alibaba Cloud Content Delivery Network accelerated domain name can be obtained in the Alibaba Cloud Content Delivery Network console.
  3. Check whether the business QPS is normal. By default, the Alibaba Cloud Content Delivery Network cache rule is based on the configured cache time. However, the disk space of nodes is limited. In the case of high-frequency user access, cached files will be replaced according to the cold degree of cold files. Files with lower access frequency will be replaced by files that access hot spots, resulting in back-to-origin. In this case, domain names with only a dozen QPS are generally encountered. We recommend that you define to warm up the resources under your domain names to ensure that they are hit on nodes.

Cache configuration check

Check whether the cache hit rate is low due to unreasonable configuration of some parameters. Perform the following operations:

  1. Check whether forced range back-to-origin is enabled. After this feature is enabled, all back-to-origin requests are sliced based on the specified range size. The function of range is also 2-sided. For scenarios where the origin is large files (over 50M), range sharding can effectively reduce network congestion encountered when downloading large files and the origin is narrowband. However, if the average size of files on the origin site is relatively small, such as files within 10M, enabling forced range back-to-origin has no optimization effect, but reduces the back-to-origin efficiency, expands back-to-origin, and reduces the hit rate.
  2. The accelerated URL of the Alibaba Cloud Content Delivery Network contains variable parameters. When your business often uses URIs with variables, and different user requests have different parameter variables, the Alibaba Cloud Content Delivery Network will be stored according to the value after the URL hash. Each different URIs will trigger back-to-origin, and the Alibaba Cloud Content Delivery Network becomes a passthrough component that loses the meaning of caching. In this case, we recommend that you enable the function of Alibaba Cloud Content Delivery Network ignoring parameter caching to uri, "?"Later resources are removed before Alibaba Cloud Content Delivery Network caching. However, if the origin or user "?"After the parameter is strongly dependent, we recommend that you switch to the Dynamic Route for CDN (D Alibaba Cloud Content Delivery Network) product. It is more flexible to use intelligent routing to return to the source. The Alibaba Cloud Content Delivery Network is a fixed edge node and a center node. For strong dependency "?"The access effect of variables is slightly lower than that of Dynamic Route for CDN (DCDN). Intelligent routing is the dynamic network quality detection planning back-to-origin path. It may be that the edge node directly returns to the origin, or the edge node returns to the central node and then back to the origin.
    Note: For example, the URL is http://example.aliyundoc.com/1.txt?timestamp=14378923. The timestamp value is a timestamp. This value is different for each access. Alibaba Cloud Content Delivery Network the URL for the first visit, that is, the URL that has not been preheated before, regardless of whether the URL complies with the Alibaba Cloud Content Delivery Network caching rules. Since this file is not yet available on the node, the first visit is definitely MISS status. But the timestamp parameter changes, so if each visit is a brand new URL, the MISS status is returned each time, which affects the hit rate.
  3. Check whether multi-replica caching is enabled on the origin server. Multi-replica caching means that the server (origin) has different Accept-Encoding headers for user requests. The origin can respond to different Vary headers and the Alibaba Cloud Content Delivery Network is cached based on different Vary headers. Requests with different Vary headers increase the number of back-to-origin requests, resulting in a decrease in the hit rate.

  4. Check whether the cache configuration is reasonable. If the cache header on the source station is not set properly or the necessary header is missing, if the Alibaba Cloud Content Delivery Network cache rule is not cached, then each access is MISS state, which affects the hit rate:
    • If the cache header is set improperly, it is mainly Cache-Control or Pragma configuration, that is, if Cache-Control is set to no-cache, no-store, max-age=0, private, or Pragma is set to no-cache on the source station, the Alibaba Cloud Content Delivery Network will perform the non-cache operation as the highest priority.
    • The lack of necessary headers means that the Response header of the origin server does not contain ETag and Last-modified. This situation also results in no caching.
    • Specifies whether to set cache headers for the source. By default, the Alibaba Cloud Content Delivery Network is cached based on the cache header priority of the origin. If an unreasonable cache header is set for the origin, such as a max-age=0 header, it overwrites the Alibaba Cloud Content Delivery Network cache.
  5. Check whether the no-caching rule is set in the Alibaba Cloud Content Delivery Network console, that is, the cache time set for a directory or a file with a certain suffix is 0 seconds.
  6. Check whether the source site has a large number of dynamic content. Currently, the Alibaba Cloud Content Delivery Network is mainly to accelerate static resources, such as CSS, JS, HTML, image, TXT, video, and other resources. For dynamic resources such as PHP, JSP, internal logic processing, and even Cookie, the resources will return the source data.
  7. Refresh operations are frequent. Alibaba Cloud Content Delivery Network the console has a scheduled refresh function, each refresh will cause all URLs that have been cached on the Alibaba Cloud Content Delivery Network to become invalid, so when accessing the same URL after refresh, it is MISS status, thus affecting the hit rate.
  8. The file is not hot enough. URLs that are not frequently accessed by users. Even if they meet all caching rules, they often risk being cached by nodes. The file cached on the Alibaba Cloud Content Delivery Network node can be understood as the end elimination system according to the heat attribute. The heat is the frequency of the file being accessed on the node. The file heat is not enough, which is actually related to the low traffic of the domain name itself to a certain extent.

References

The documents related to Alibaba Cloud Content Delivery Network caching are as follows:

Application scope

  • CDN