Welcome to Centmin Mod Community
Become a Member

WebPerf How to Classify Your CDN’s Cache Hit Ratio and Correlate Metrics

Discussion in 'All Internet & Web Performance News' started by eva2000, Mar 10, 2016.

Tags:
  1. eva2000

    eva2000 Administrator Staff Member

    54,946
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,812
    Local Time:
    5:25 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    [​IMG]

    Even with a CDN implemented, performance degradation and increased latency is always an unfortunate possibility for any web application.

    Consider for a moment what’s involved in a single web request from end-client to the origin: The request is fragmented and encapsulated into datum packets and sent out across the Internet backbone of network of cables, traversing thousands of switches, routers, and data centers along parallel ISP routes.

    You Can’t Control Sharks


    Bearing this in mind, one has to accept that the intrinsic nature of such complex systems are inclined to obey Murphy’s Law that states: “If anything can go wrong, it will.” Notable examples of things going wrong include sharks eating fiber optic submarine cables, a Georgian woman scavenging for copper, and cyber-terrorist-scuba-hackers.

    You Can Control Cache


    Mother nature and human curiosity aside, there are certain variables in your control. One of these is your CDN’s cache. When configured correctly, it can provide your website with 99.99% resource utilization, maximum speed, and minimum latency.

    Take Control: Cache Control


    The configuration rules which govern how, when, and why your web assets are stored in a web servers’ cache are collectively referred to as a Cache-Policy.

    A well configured Cache-Policy minimizes Cache Misses, maximizes Cache Hits, and maintains a basal level of “cache warmth.” Deciphering the multiple configuration files that govern these policies can be a daunting task, even for a seasoned sys admin. In our follow-up PDF on improving your cache hit ratio, we touch on some of these configurations. However, the best way to mitigate disaster is to avoid it all together.

    This is where cache hit ratio monitoring and metric analysis play a pivotal role.

    Introducing Cache Hit Ratio


    Cache hit ratio measures the percentage of requests your CDN is able to serve from its own internal cache (Cache HIT: Client to Edge) verse requests for assets in which the CDN has to pass along to your Origin (Cache MISS: Client to Edge to Origin).

    [​IMG]

    High cache hit ratios result in faster websites while low cache hit ratios result in slower websites, increased origin stress, sharp increases in latency, and dropped connections. In fact, requests that miss the cache (via CDN edges) often result in longer response times than requests sent directly to the origin.

    Simply put, your cache hit ratio is the single most important metric in representing proper utilization and configuration of your CDN.


    Keeping Score of Your Cache Hit Ratio


    Your cache hit ratio relationship can be defined by a simple formula:

    (Cache Hits / Total Hits) x 100 = Cache Hit Ratio (%)

    • t = time frame of observation
    • Cache Hits = recorded Hits during time t
    • Total Hits = all requests recorded during time t

    In the actual formula, time t becomes irrelevant as it’s cancelled out. Also keep in mind that the ratio must be less than or equal to 100 as the total amount of requests must be greater than or equal to Cache Hits.

    For any site, a cache hit ratio of 99% is possible. This depends, however, on the functionalities and design of the website on the origin server. Websites with a lot of user-generated content or more frequent updates may have a lower cache hit ratio.

    With that said, if your cache hit ratio is below 80% on static files, your CDN is either poorly configured or not performing properly.

    Classifying Your Cache Hit Ratio


    While cache hit ratios measure the performance of the CDN cache in terms of percentage value, there are other ways to label cache performance. This is often done with the following cache terms.

    • Cold Cache: A cold cache is either empty, or too stale to be used. Cache hit ratios typically hover below 15% or display sharp negative slope tendencies towards 0%.
    • Warm Cache: The most ambiguous of the three cache states, warmth is a relative state: hot cache decreasing in performance (turning cold) or a cold cache increasing in performance (turning hot while priming assets from the origin).
    • Hot Cache: What every cache strives to be – efficient, fast and utilized. Pretty straightforward.

    Below we are going to look at some examples of each. In these real-client examples, monitoring is done through the MaxCDN dashboard. However, if you’re using another CDN or want to customize your monitoring, we show you how to do this below.

    Cold Cache


    Your cache is considered “cold” when the CDN has no assets to provide end-users upon request. The edge simply re-routes the request to the origin without caching it for future use, effectively doubling the total response time.

    [​IMG]
    (0 / 396,019) x 100 = 0% Cache Hit Ratio

    Warm Cache


    Below is an example of a hot cache turning cold. In this particular example, the user implemented a change to their Cache-Policy enabling the caching of query strings (read more in the PDF). Because the cache maintained some level of warmth, it is generally better than an outright cold cache .

    [​IMG]
    (654,930 / 1,462,541) x 100 = 51.87% Cache Hit Ratio

    Hot Cache


    Leaving the best for last, here’s a prime example of a hot cache. In one day, the user had nearly 53 million requests. This roughly translates to only 1 cache miss per every 1000 requests. Now we’re cooking.

    [​IMG]
    (52,453,064 / 52525710) x 100 = 99.86% Cache Hit Ratio

    Correlating Cache Ratio Metrics


    For web administrators running high traffic sites, downtime, latency degradation, and outages can turn a successful business into a crippled one.

    Aggregating your web applications data from front-to-back (RUM data, synthetic monitoring, server-side resource usage metrics) is not something your average spreadsheet can handle with grace. This is where a robust API framework for your CDN comes in handy.

    At MaxCDN, we offer an extensive knowledge base (MaxCDN One) covering our RESTful API support for Python, Ruby, NodeJS, JS, PHP, .NET and Perl. We are also continuously updating MaxCDN One with tutorials on how you can quickly compile your zone metrics for aggregation into popular visualization libraries.

    Some visualization methods include:

    Now Go Increase Your Cache Hits


    MaxCDN has put together a PDF addressing the top three causes of poor cache performance. In addition to addressing the causes, we also offer tactics you can use to increase the number of cache hits. Whether you use MaxCDN or not, you can use this post and the PDF as a guide to maximize your cache hit ratio and improve the loading time of your website.

    The post How to Classify Your CDN’s Cache Hit Ratio and Correlate Metrics appeared first on MaxCDN Blog.

    Continue reading...