The Runtime Theory
mediumServerInternals#read-path#cache-invalidation

How Would You Design a Cache-Backed Read Service?

A design prompt about workload assumptions, cache keys, freshness, invalidation, overload, and evidence that a cache is needed.

TRT practice prompt — not a verified question from a named employer.

The Runtime Theory Team1 min read

A strong answer

I would first clarify read and write rates, freshness requirements, object size, geographic distribution, and the impact of stale data. I would estimate whether database load or latency is actually a problem before introducing another stateful component.

For a read-through or cache-aside path, define a key that includes every dimension that changes the response, including tenant or authorization context where appropriate. On a miss, the service reads the source of truth and fills the cache with a documented TTL. Updates can invalidate or replace the entry; concurrent fills and updates can race, so the policy must be tested.

I would define behavior for cache failure, a thundering herd, and hot keys. Metrics should include hit rate, stale responses where measurable, eviction, backend load, and tail latency. The cache must not become an accidental authorization boundary.

Follow-up direction

Compare TTL-only expiration with explicit invalidation and explain the freshness and operational trade-offs.

This answer walks

Practice follow-ups

  1. 01How do you prevent cross-user cache leakage?
  2. 02What happens when the cache is unavailable or misses concurrently?
  3. 03How stale can a response be before it violates the product requirement?

More interviews in this topic

One dispatch a week

The trace behind each question, the tradeoff that explains it, and one technical dispatch per week — no noise.

One technical dispatch per week. No noise.

Not started

Sign in to save your learning progress.

Sign in to save