Read-Heavy Hot Key
All copies of the hot key expire at the same instant.
Topic tools
Layout updated
Prompt
All copies of the hot key expire at the same instant.
One famous key is like one checkout counter with a long line. Add read copies and control refills so every customer does not run to the warehouse.
Constraints
- Keep hot reads from overloading the source database.
- State how old a cached answer is allowed to be.
Think first
Take five minutes to state the failure, the evidence you need and your first safe move.
Staged reveal
First move
The database owns writes; caches hold replaceable versioned copies.
What to check
Watch per-key request concentration, concurrent fills and source saturation.
Recovery
expiry, prewarm hot copies and refreshes; a fleet-wide average hit ratio can hide this single-key outage.
What you give up
More copies increase reads served, but also increase update work. A single write-heavy key needs a different data or admission policy.
Architecture and technical reference
High-level design
- Edge
- State
━━ Synchronous┄┄ Asynchronous···· Recovery / control▧ Fault
Each arrow is one interaction. Request, background and recovery branches are not one linear transaction.
Read the 3 flow steps
Problem statement
One key receives 40% of reads while every other looks healthy. How do you add read capacity without creating conflicting writers?
Functional requirements
- Read a popular value from several cache copies.
- Refresh those copies when the source changes.
- Continue serving when a cache copy fails.
Non-functional requirements
- Keep hot reads from overloading the source database.
- State how old a cached answer is allowed to be.
Entities
| Entity / logical owner |
|---|
| Authoritative state |
API design
| Operation / input | Response and retry contract |
|---|---|
Decision contract | Identify acceptance, retry identity, version/ and the response on uncertainty. |
High-level design component walkthrough
Heavy Read Traffic
Skew on one key
Why, tradeoff and connected operations
An application or user-facing endpoint starts or receives this flow.
Tradeoff: High skew even if average traffic low
Connected operations: Submit request
Read Router
Detect and spread hot reads
Why, tradeoff and connected operations
Centralize admission and routing while keeping business-state ownership downstream.
Tradeoff: Routing table skew and control overhead
Connected operations: Submit request; Pass validated input
Redis / Replicated Cache Copies
Independent capacity per copy
Why, tradeoff and connected operations
Redis for shared ephemeral cache/index state; process-local caches remain local. Cache state is not the durable business authority. Keep frequently accessed derived state near the request path; rebuild it from its declared authority.
Tradeoff: Every update fans out to copies
Connected operations: Pass validated input; miss / refresh
PostgreSQL / Source of Truth
Fallback and updates
Why, tradeoff and connected operations
: PostgreSQL. Relational tables and constraints own this state. Logical tables shown within the same business database are not separate databases; only at the defined transaction boundary. Use transactional constraints for related authoritative records; indexes follow the access pattern.
Tradeoff: Fallback can become bottleneck
Connected operations: miss / refresh
Engineering control room
Deep dives — decisions, failures and recovery
Open a deep dive to follow the steps, try an example and see how recovery works.
Tradeoffs and alternatives
| Decision | Tradeoff / alternative and recovery implication |
|---|---|
| Keep one source for the current value | More copies increase reads served, but also increase update work. A single write-heavy key needs a different data or admission policy. |
| Recover a hot copy without flooding the source | Test a value change while one copy is offline. Choose how long old data may be served and how the returning copy learns the latest version. |
| What happens if a region fails? | More independent caches improve availability but increase freshness-management work; synchronous updates reduce staleness at a coordination cost. |
| Expiry, eviction and cold-start capacity | Prewarming and spare capacity cost resources; waiting longer for a shared fill trades latency for reduced origin work. |
Production scars & failure modes
All copies of the hot key expire at the same instant.
Look for: Watch per-key request concentration, concurrent fills and source saturation.
Recovery and invariant: expiry, prewarm hot copies and refreshes; a fleet-wide average hit ratio can hide this single-key outage.
| Component / failure | Impact | Recovery mechanism | Alternative / tradeoff |
|---|---|---|---|
| Primary failure / race | One key receives 40% of reads while every other looks healthy. How do you add read capacity without creating conflicting writers? | Replicate the hot read value and spread requests; preserve one write authority. Bound fallback work when a replica fails. | Extra copies improve read capacity but increase invalidation . A single write-hot key needs a different semantic or rate-limit decision. |
| Recovery follow-up | Change the value while one cache replica is disconnected. Describe version propagation, and a stale-read bound. | Replicate the hot read value and spread requests; preserve one write authority. Bound fallback work when a replica fails. | State the guarantee you relax and how you detect recovery. |
90-second interview summary
For this hot-key drill, I would first identify the real concentration of traffic instead of assuming that a larger cache cluster automatically solves it. If half the requests target one key, ordinary key hashing still sends those reads to one owner while most shards stay idle.
The source database remains the write authority. I would replicate versioned read copies, spread requests across them and preserve the source version on every fill. Cache copies are disposable, and adding them must not create several places allowed to decide the current business value.
The failure case is more important than the warm hit ratio. A lost copy or simultaneous expiry can send a surge to the source, so I would combine concurrent fills, vary expiry, prewarm known hot values and cap global fallback work. Stale serving is allowed only for an explicit field/age policy.
Across regions, I would recover the source authority before promoting any cache into a business writer, and warm surviving copies gradually. I would measure per-key demand, refill concurrency, source saturation and stale-value age. The central tradeoff is more replication and freshness management for lower read latency, while preserving one durable version owner and a source database that survives cache failure.
Explain it without looking
Explain keep one source for the current value
Reveal answer
The database owns writes; caches hold replaceable versioned copies.
A cache failure changes where reads run, not which copy is allowed to decide a new value.
More copies increase reads served, but also increase update work. A single write-heavy key needs a different data or admission policy.
Explain recover a hot copy without flooding the source
Reveal answer
Spread reads across healthy copies and limit replacement fetches.
A cache outage should not create a database outage while the fleet is rebuilding.
Test a value change while one copy is offline. Choose how long old data may be served and how the returning copy learns the latest version.
Explain what happens if a region fails?
Reveal answer
Spread surviving read copies without giving an old copy permission to write.
Read replication solves load concentration without solving regional write durability.
More independent caches improve availability but increase freshness-management work; synchronous updates reduce staleness at a coordination cost.
Explain expiry, eviction and cold-start capacity
Reveal answer
Test the cache as a finite resource, not a permanently warm lookup table.
The source database must survive the exact cache failure the system is trying to recover from.
Prewarming and spare capacity cost resources; waiting longer for a shared fill trades latency for reduced origin work.
Revision checklist
Revision checklist
- Reconstruct keep one source for the current value: The database owns writes; caches hold replaceable versioned copies.
- Reconstruct recover a hot copy without flooding the source: Spread reads across healthy copies and limit replacement fetches.
- Reconstruct what happens if a region fails?: Spread surviving read copies without giving an old copy permission to write.
- Reconstruct expiry, eviction and cold-start capacity: Test the cache as a finite resource, not a permanently warm lookup table.
- Name the authoritative state, boundary, retry identity and failure-domain durability guarantee.
- Explain one alternative and exactly which guarantee you would relax.
- Redraw the request and recovery paths without looking; mark what required a hint.
On this page
- Prompt
- Constraints
- Think first
- Staged reveal
- High-level design
- Problem statement
- Functional requirements
- Non-functional requirements
- Entities
- API design
- High-level design component walkthrough
- Engineering control room
- Deep dives — decisions, failures and recovery
- Tradeoffs and alternatives
- Production scars & failure modes
- 90-second interview summary
- Explain it without looking
- Revision checklist