The interview problem

Practice prompt

A dashboard cache works well until a nightly scan reads thousands of unique keys and evicts the hot working set. Design admission control that distinguishes a miss from a reason to retain an item.

Original practice, not a reported company interview. All worked numbers are illustrative. Interview date: not applicable. Written October 3, 2026.

1. Scope and assumptions

Assume a fixed-size cache and workloads with both repeated reads and one-time scans. Admission and eviction are separate decisions. Variable object sizes and miss costs may require a weighted policy beyond simple frequency.

2. Architecture and decisions

Request → cache lookup → backend fetch → frequency update → candidate-versus-victim admission → bounded cache

Keep a compact, aging estimate of recent access frequency, including requests that miss. On replacement, compare the incoming candidate’s estimated usefulness with the proposed victim. A small recency window lets genuinely new hot items demonstrate reuse before competing for the main cache. Age history so yesterday’s popular items do not remain protected forever.

Choose a size-aware rule if objects vary substantially: saving one expensive large miss may or may not justify evicting many small hot items. Cap metadata cost and account for approximate counter collisions. Keep a baseline LRU implementation for trace comparison rather than assuming a sophisticated policy always wins.

3. Work through the example

A 100-entry LRU cache holds 100 frequently reused keys. A scan of 1,000 distinct new keys replaces all of them; the next pass over the 100 hot keys incurs 100 misses. Under an illustrative admission rule where each hot key has frequency 20 and each scan key frequency 1, scan keys lose admission and the hot set survives. Real aging and window effects change this idealized result.

4. Failure cases and trade-offs

Frequency history can resist a legitimate workload shift. Approximate counters can overestimate a cold key. Metadata contention may erase backend savings at high concurrency. Scan resistance trades immediate admission of new objects for preservation of established value; a recency window softens that tradeoff.

5. Validation and acceptance

Replay mixed traces with scans, bursts, a new hot set and skewed object sizes. Measure backend cost saved and byte hit rate, not only request hit rate. Include metadata CPU and memory in the comparison.

6. Follow-ups and self-review

How quickly should frequency history decay? Reward separation of admission and eviction, adaptation to change and size/cost-aware evaluation.

Sources and related practice

TinyLFU studies approximate frequency-based cache admission; this trace and operational policy are original examples.

Read the primary technical reference

Reference retrieved October 3, 2026. Retrieval date is not an interview or source publication date. The reference supports the named concept; scenario, architecture, examples and rubric are original.

Continue with Design a distributed cache; Cache semantically similar model requests.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.