Testing linear elastic caching
To make sure our idea holds up in the true world, we carried out intensive experiments utilizing two major sources:
- Manufacturing workloads: We built-in the system into Spanner.
- Public traces: We examined in opposition to quite a lot of publicly obtainable cache traces from trade benchmarks to make sure the outcomes weren’t particular to Google’s infrastructure.
Manufacturing workloads
We developed a sensible algorithm that assigns a time-to-live (TTL) to the cached web page on every web page request based mostly on the web page’s entry patterns and prices. As a result of Spanner handles billions of requests per second, this TTL prediction mannequin must be extremely light-weight. We opted for a shallow choice tree that may be translated into a couple of traces of C++ code. The ensuing code can be simply interpretable and gives useful insights on the workload traits. This mannequin considers options reminiscent of the dimensions of the information, the price of a cache miss (when knowledge isn’t within the cache and the system must retrieve it from another, slower system like a disk), and the kind of database operation being carried out to foretell the optimum TTL for every web page.
We built-in the elastic caching coverage into Spanner’s manufacturing servers over a number of months. In comparison with a typical fixed-size cache, the outcomes have been substantial:
- Reminiscence utilization: Lowered by 15.5%.
- Cache misses: Elevated by solely 5.5%.
- Complete value of possession (TCO): Lowered by roughly 5%.
Crucially, as a result of the algorithm is “cost-aware,” the small enhance in cache misses was focused on knowledge that’s low cost to fetch from storage, that means the affect on precise I/O prices was a negligible 0.5%.
Public traces
We additionally evaluated our elastic caching strategy utilizing a number of publicly obtainable cache traces. We used an optimized implementation of the grasping twin measurement frequency (GDSF) eviction algorithm — a generalization of the well-known LRU coverage that permits for pages of various sizes — as a hard and fast cache measurement baseline coverage.
We thought-about 4 variants of elastic caching relying on which ski rental algorithm we used and whether or not or not we used a machine discovered mannequin. For the reason that obtainable public traces haven’t got application-level options obtainable for coaching, we didn’t implement choice bushes for prediction. As an alternative, we developed a easy studying technique that splits every hint in half and makes use of the primary half for coaching. For every particular person web page within the coaching hint, we computed the very best TTL for the web page that minimizes the fee over the coaching hint.
For the reason that conduct of the cache modifications relying on what’s initially within the cache, a standard apply, generally known as “warming up”, is to make use of some prefix of the cache hint to populate the cache however not really measure efficiency on it. We warmed up all caches with at some point’s price of requests from the second half of the hint and used the remainder for testing and measurements. In the course of the take a look at hint, if we encountered a web page that was seen throughout coaching, we set the TTL to be the very best precomputed TTL for that web page. In any other case, we set the TTL utilizing both the breakeven or randomized insurance policies.

