liveBook · Manning

Multi-level caching

As explained in Grokking Software Architecture

Multi-level caching is a caching technique that organizes multiple cache layers with different locations or performance characteristics.

When a shared cache is still a millisecond away, a server can keep a local copy close at hand. Multi-level caching puts a fast local cache (L1) in front of a shared distributed cache (L2)—like a sticky note on each desk and a whiteboard everyone can read. section 10.6

The speed comes with a coordination problem: when data changes, every server’s local copy must be refreshed or discarded. Otherwise, one page may show a new profile picture while another shows the old one. section 10.6

Local caching is most suitable when:

  • The data is practically immutable, such as a list of US states, ZIP codes, or historical tax rates. section 10.6
  • The extra speed is worth the risk and effort of keeping local copies consistent. section 10.6
Figure 10.8 Multi-Level Caching: The Local Cache (L1) is like a personal sticky note for blistering speed, while the Distributed Cache (L2) is a shared whiteboard for the entire system.

The sticky-note and shared-whiteboard comparison illustrates how local and distributed cache layers differ. section 10.6

How Grokking Software Architecture covers it

How deep it goes
Explains the L1/L2 hierarchy and stale-data risk, but gives no implementation steps.
Examples
Uses a sticky note and shared whiteboard analogy, plus ZIP codes, tax rates, and profile pictures.
What you can do after
Evaluate whether local caching’s speed benefit suits rarely changing data despite its invalidation risks.
How it connects
Connects local caching to distributed caching, Redis, cache invalidation, and stale data.

Also explained in

Compare how 2 books explain multi-level caching →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.