Caching for Modern Tiered Storage

Jul 18, 2024

English translation of the Chinese original by PsiACE, first published on 2024-07-18. Source: Databend blog original. This translation was prepared for this archive; the figures are served from this archive.

Based on my July 13, 2024 talk at Data Infra Study Group (Episode 19):

Hi everyone, I'm Chojan Shang (PsiACE), an engineer at Databend. It's been a while since I last spoke at Data Infra, and today I want to talk about Caching for Modern Tiered Storage. Caching is a staple of data-intensive systems like Databend, yet recent research has surfaced several new design trends, including approaches combined with machine learning. This talk walks through those ideas and the papers behind them.

Part 1: Caching vs. Tiering

In a full tiered storage model, different hardware layers (memory, flash, HDD, remote object storage, tape, and so on) form a pyramid. Every layer has to account for its latency, bandwidth, and data movement trade-offs. To keep the discussion focused, we can simplify tiered storage into two layers:

  1. Capacity tier: large, slower, cheap—meant for storing large volumes of data.
  2. Performance tier: smaller, faster, more expensive—meant for holding hot data on the critical access path.

The goal of tiered storage is straightforward: use a small amount of fast storage to lift overall system performance while keeping total cost of ownership under control.

Tiered storage pyramid: performance tier and capacity tier

Caching and tiering are two classic ways to optimize data access across these layers. Both keep frequently accessed data on faster media, but they differ in how data moves:

  1. How data moves:
    • Caching copies data from the capacity tier to the performance tier and evicts the least useful entries. The capacity tier always keeps the full copy.
    • Tiering moves data between layers; the capacity tier and performance tier together form the complete dataset.
  2. Movement frequency and granularity:
    • Caching operates at fine granularity and high frequency, reacting quickly to dynamic workloads.
    • Tiering operates at coarser granularity and lower frequency, typically on a schedule of hours or days.
  3. Typical use cases:
    • Caching fits latency-sensitive systems such as high-traffic web services and interactive analytics.
    • Tiering fits cost-driven, large-scale storage systems and data lakes.

Comparison between caching and tiering

Both classic warehouses and modern cloud data warehouses can be simplified into a "local vs. remote" two-tier model, where either caching or tiering can deliver strong gains. Earlier HDFS-based warehouse papers studied tiering extensively, whereas modern object-storage-native cloud warehouses (such as Databend and Snowflake) rely much more heavily on caching. A typical cloud warehouse spans three tiers: memory for metadata and query results, local SSD for active working data, and remote object storage as the durable backing store. Even persisting computed result sets back to object storage can be viewed as a form of caching, since compute time far outweighs storage access time.

Three-tier storage layout in modern cloud data warehouses

Since periodic tiering can look cheaper on paper, why do modern cloud data warehouses overwhelmingly favor caching over tiering?

  1. Economics: Managed cloud object storage and EBS eliminate hardware procurement, refresh cycles, and operational overhead. Paired with pay-as-you-go pricing, total maintenance cost is often lower.
  2. Elastic compute instances: Cloud-native nodes spin up and shut down constantly, which makes scheduling tiering transitions awkward. Caching avoids that—on a miss, you simply fetch and cache, with lower opportunity cost. And because tiering moves data rather than copying it, terminating an instance creates data-management and durability headaches, whereas a cache can simply be dropped.
  3. Multi-tenancy and dynamic workloads: Workloads vary sharply across tenants and queries. Caching adapts organically, while hand-crafting tiering policies for every pattern is hard to sustain.
  4. Shrinking hardware performance gaps: Modern fast storage has narrowed the speed gap between tiers from 100x+ down to under 10x in many cases. Because the capacity tier holds the complete dataset, a cache can spill or route requests straight to the capacity tier when the performance tier saturates, utilizing both layers rather than bottlenecking on one.

Part 2: Paradigm Shift — LRU-like vs. FIFO-like

Eviction algorithms have been undergoing a clear shift from traditional LRU-like designs toward FIFO-like designs. We typically evaluate cache algorithms along five dimensions:

  • Efficiency: Lower miss ratio means fewer backend reads to the capacity tier, keeping hot data in the performance tier. Depending on the workload, byte miss ratio may matter more than object miss ratio.
  • Throughput: How many requests per second the cache can serve.
  • Scalability: On modern multi-core CPUs, cache performance should scale with cores and threads—or at least not degrade under high concurrency.
  • Flash-friendliness: Many modern deployments (such as Google's object storage and Meta's CacheLib) cache on SSDs rather than RAM. Minimizing writes and write amplification directly extends flash lifetime.
  • Simplicity: Simple algorithms like LRU and FIFO are easy to implement and port across systems, which is why they dominate production, whereas complex ML-heavy schemes often struggle to see adoption.

Five evaluation dimensions and taxonomy of cache eviction algorithms

LRU-like policies remain the most familiar—Databend itself uses a classic optimized LRU implementation—because access patterns exhibit temporal locality. Under high concurrency, however, LRU-like designs hit scaling bottlenecks, often requiring mitigations like hot/cold partitioning or front-end FIFO queues.

FIFO-like policies are common on flash caches because write order matches eviction order, reducing write amplification. To improve multi-core scalability, some in-memory caches (such as RocksDB's) have also moved toward FIFO-like designs. A classic example is FIFO-Reinsertion (another way of describing the CLOCK algorithm), and newer designs like S3-FIFO build on empirical workload insights to achieve strong miss ratios.

How to Tell LRU-like and FIFO-like Apart

An LRU-like algorithm updates a global data structure (such as unlinking and re-inserting a node in a doubly linked list) on every cache hit. Paradoxically, as hit ratio rises, lock contention and pointer updates spike, causing throughput to drop. Even RL-based algorithms like LeCaR fall into the LRU-like family because they build on LRU and LFU underneath.

FIFO-like algorithms avoid mutating a global structure on cache hits, so higher hit ratios don't lengthen queues on the bottleneck resource. They fall into two main groups:

  • FIFO-based structures: CLOCK variants, S3-FIFO, QDLP, and SIEVE.
  • Global-structure-free sampling: algorithms like LHD, LRB, and Hyperbolic that pick eviction candidates via random sampling, keeping throughput rising alongside hit ratio.

Reasons for the shift from LRU-like to FIFO-like caches

If FIFO-like caches scale so well, why weren't they widely used in memory before? Traditionally, hit ratio was the primary yardstick, and plain FIFO lagged behind. Large-scale workload studies over the past few years showed that weak-LRU designs using lazy promotion—such as FIFO-Reinsertion—can actually beat standard LRU overall.

Two design patterns—Lazy Promotion and Quick Demotion—help guide both LRU-like and FIFO-like designs, allowing modern FIFO-like algorithms to match state-of-the-art hit ratios (such as S3-FIFO on object storage/CDN traces and SIEVE on web workloads).

Lazy Promotion and Quick Demotion cache design patterns

  • Lazy Promotion promotes an object only at eviction time: if it was accessed since insertion, re-insert it instead of evicting it. FIFO with lazy promotion acts as a lightweight approximation of LRU.
  • Quick Demotion avoids the opportunity cost of letting one-hit wonders travel through the whole cache. A typical setup places a small FIFO queue in front of the main cache and quickly evicts anything that isn't hit there. Admission filters can be seen as an even more aggressive form of quick demotion, though their aggressiveness often hurts miss ratio.

Comparison between SIEVE and FIFO-Reinsertion

SIEVE and FIFO-Reinsertion look very close—both keep objects that were accessed before eviction—but differ in one key detail:

  • SIEVE leaves surviving objects in place while a moving pointer scans newer entries, naturally clustering survivors together.
  • FIFO-Reinsertion moves surviving objects back to the head of the queue, mixing old and new entries together.

As a result, SIEVE gets a Quick-Demotion-like effect for free, striking a clean balance between discovering newly popular items and retaining long-lived hot items.

Part 3: Caching and Machine Learning

Combining caching with machine learning has been widely studied. A common setup uses supervised regression to predict a utility score and evicts the lowest-utility objects.

ML-based caches run into two core obstacles:

  • Model overhead: Frequent training and inference to keep up with shifting access patterns can be expensive.
  • Metadata overhead: Tracking features to infer workload patterns or select policies requires substantial memory and bookkeeping.

Two main approaches to combining machine learning with caching

Broadly, ML enters caching in two ways:

  • Improving the eviction policy itself (deciding which objects to keep or evict).
  • Selecting the best existing eviction policy for the current workload.

LRB (Learning-based Replacement) overview

For example, LRB (Learning-based Replacement) uses over 40 per-object features to predict the next access time and evicts objects predicted to be needed furthest in the future. More features improve accuracy, but memory and compute overhead quickly rule it out for resource-constrained, high-throughput caches. Batching helps somewhat, yet gradient-boosted trees still take milliseconds to tens of milliseconds per train/predict cycle—far too slow for the hot path.

Policy selection with LeCaR and CACHEUS

For policy selection, multi-armed bandit reinforcement learning (such as LeCaR and CACHEUS) has been popular, with two well-known drawbacks:

  • Policy ceiling: Performance is bounded by the base heuristics in the pool. LeCaR mixes only LRU and LFU, while CACHEUS adds policies tailored for scan and loop patterns.
  • Delayed rewards: RL feedback arrives late, slowing adaptation when workloads shift and hurting hit ratio.

Supervised approaches like FTRL and gradient-boosted trees have seen wider study in CDN caching, where raw lookup throughput is less of a bottleneck. In all cases, however, metadata collection and model overhead remain the main barriers to broad production adoption.

Part 4: Learning-Based Caching — Toward Lightweight, Low-Overhead Designs

To fit modern high-concurrency, high-throughput in-memory caches, research on learning-based caching has shifted away from chasing miss ratio alone toward throughput, scalability, and lean metadata.

Group-level learning in GL-Cache

One notable direction is group-level learning, which I covered earlier in a walkthrough of GL-Cache. By grouping objects and aggregating learning signals per group, training and inference costs are amortized across many objects. The trade-off is implementation complexity and update cadence—in the paper, training and prediction happen on a coarse schedule (tens of milliseconds per run), keeping ML off the hot path at the cost of slower reaction to sudden workload shifts. Even so, the idea has inspired follow-up work applying block-level grouping and framing to caches.

MAT (Machine Learning At Tail) overview

Another practical idea is pairing ML with a heuristic filter to shrink the number of samples. MAT (Machine Learning At Tail) places the ML model at the tail of a heuristic cache so inference runs only when an object is about to be evicted. Better yet, if the ML module ever becomes a bottleneck, the cache can fall back to the heuristic alone. Because MAT builds mainly on LRU-like structures, though, its concurrency scalability remains limited.

ALPS: sketch-based feature tracking and policy prediction

Using sketches for feature management is another promising direction. Sketches already appear in caches like TinyLFU and Bloom-filtered designs. ALPS splits the access stream into frames, summarizes heuristic signals (recency, frequency, etc.) into compact sketches, and uses ML at the end of each frame to choose the best heuristic policy for the next frame. In theory this delivers low overhead and high throughput, though its published experiments ran on high-end DGX hardware.

Together, group-level learning, tail filtering, and sketch-based features show how learning-based caches are steadily moving toward leaner, more practical designs.

Part 5: What Often Gets Overlooked

Finally, two areas that didn't fit cleanly into the earlier sections deserve attention.

Cache admission policies overview

Eviction gets most of the spotlight, but admission matters just as much—especially at scale. Admission decides what enters the cache in the first place, either actively or passively. In large databases, active admission lets you target specific tables for caching, improving performance while cutting unnecessary SSD writes. Passive admission can be viewed as an aggressive form of quick demotion.

Two well-known heuristic admission policies are TinyLFU and Window-TinyLFU (used in Rust's Moka and Java's Caffeine). Still, strong general-purpose admission policies remain surprisingly scarce. Putting a simple Bloom filter in front of LRU, for instance, rejects objects on their first request and admits them only on the second—great for scan resistance, but blind to short-term locality, so it often ends up with a worse miss ratio than plain LRU.

Cross-tier caching overview

Cross-tier caching is another open area. The move toward FIFO-like algorithms makes it easier to use the same policy across both memory and disk, simplifying maintenance. Yet memory and flash still differ in access characteristics and wear constraints, and a three-tier cache needs coordinated ways to manage hot and warm data across media. Research here is still sparse, making cross-tier coordination one of the most worthwhile problems left to explore.

https://psiace.me/posts/atom.xml