Try
↑ ↓ move↵ openesc close

Curriculum · Module 01, Scaling a Service

Lesson 2 · 7 topics · 38 min · Beginner · 0/7 done

Caching and eviction

A cache is small, so something has to leave. Which policy decides, and what happens when the workload changes.

What each topic covers

  • Popularity is skewed, so keeping a few keys close answers most requests.
  • Four ways to decide what stays, traced on a short request sequence.
  • Watch hit rate over time, then swap the popular keys mid-run and see which cache keeps up.
  • Hit rate for each policy on a steady workload, then what a moved hot set does to LRU, LFU and TinyLFU.
  • Compute the best possible hit rate for a Zipf workload, see how little each doubling buys, and measure the gap each policy leaves.
  • A time-to-live creates a cliff. Count the queries a stampede sends, then compare coalescing, leases, stale serving and early refresh.
  • Three checks on FIFO, LFU after a product launch and TinyLFU admission, plus the papers behind them.

Topics

  1. 1Why a small cache works at all4 min
  2. 2FIFO, LRU, LFU, and TinyLFU5 min
  3. 3Move the hot keys under four policies7 min
  4. 4Why plain LFU stays stuck after a shift5 min
  5. 5How big a cache do you need7 min
  6. 6When a hot key expires7 min
  7. 7Check the eviction rules3 min

Practise this lesson

14 interview questions on caching, with worked answers and sources.

Practise these

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms