How to Classify Your CDN’s Cache Hit Ratio and Correlate Metrics
April 1, 2015 | Adam OssowskiEven 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 SharksBearing 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 CacheMother 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 ControlThe 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 RatioCache 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). 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 RatioYour 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
Classifying Your Cache Hit RatioWhile 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.