CoursesBuilding Scalable Services

Caching in Depth

Write policies and what each can lose, the stampede when a hot key expires, sizing a cache for its working set, and invalidating copies you cannot see.

Lessons
6
Exercises
35
Minutes
39

Start Cache-Aside, Write-Through, Write-Behind

  1. 1

    Cache-Aside, Write-Through, Write-Behind

    After this lesson you can choose how writes reach the cache, say what each policy can lose or serve stale, and order the steps so a failed write never leaves a phantom in the cache.

    DebugFill blankMultiple choiceTrace
    5 exercises
    6 min
  2. 2

    The Stampede

    After this lesson you can compute what a hot key's expiry does to the origin, and choose between a lock, an early refresh and stale-while-revalidate to stop it.

    DebugMultiple choiceShort answerTrace
    5 exercises
    6 min
  3. 3

    Sizing and Eviction

    After this lesson you can size a cache from its working set, read the hit-rate curve for the size where more memory stops paying, and pick the eviction policy the access pattern needs.

    DebugMultiple choiceShort answerTap
    5 exercises
    6 min
  4. 4

    Invalidation at Scale

    After this lesson you can cache the misses that hammer the database, invalidate copies in caches you cannot see, and keep a TTL as the backstop for the invalidation that never arrived.

    DebugFill blankMultiple choiceTrace
    5 exercises
    6 min
  5. 5

    Checkpoint: Caching in DepthCheckpoint

    Write policies, stampedes, sizing and invalidation for a system you have not seen before.

    DebugMultiple choiceShort answerTap
    7 exercises
    6 min
  6. 6

    Boss: The Pricing ServiceBoss

    One design carried from the ask to the incident: the question, the hit rate the database needs, the price key, the cache layers, the hourly stampede, the instance that kept a stale price, the revised write path, and the tradeoff you have to defend.

    Code orderMultiple choiceShort answerTrace
    8 exercises
    9 min