Hot-Key Write Propagation
Version 12 arrives before version 11 at one cache replica.
Topic tools
Layout updated
Prompt
Version 12 arrives before version 11 at one cache replica.
A cache update is a delayed announcement of a newer fact. Announcements can arrive twice or in the wrong order.
Constraints
- Reject a cache update older than the installed version.
- Keep deletes effective despite delayed updates.
Think first
Take five minutes to state the failure, the evidence you need and your first safe move.
Staged reveal
First move
The source assigns versions and each cache rejects older replacements.
What to check
Record the highest applied version and invalidation backlog.
Recovery
Reject regressing updates, preserve versioned deletes and repair from authoritative state; message arrival order is not the data version.
What you give up
Keeping version barriers uses memory. Rechecking the source gives stronger freshness but increases read cost and dependency on the source.
Architecture and technical reference
High-level design
- Compute
- State
- Messaging
━━ Synchronous┄┄ Asynchronous···· Recovery / control▧ Fault
Each arrow is one interaction. Request, background and recovery branches are not one linear transaction.
Read the 4 flow steps
Problem statement
A read of version 7 starts before a write of version 8. The invalidation reaches the cache before the slow read fills it. What happens?
Functional requirements
- Update or delete a value at its source.
- Send the new version to cached copies.
- Ignore updates older than the installed version.
Non-functional requirements
- Reject a cache update older than the installed version.
- Keep deletes effective despite delayed updates.
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
Writer
Update value
Why, tradeoff and connected operations
Isolate this operation so it can scale and fail independently from storage.
Tradeoff: Concurrent writers reorder events
Connected operations: Persist state
PostgreSQL / Authoritative DB/Leader
monotonic version
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: Leader / cost per version
Connected operations: Persist state; Publish event
Kafka / Invalidation Event Bus
Fan out version updates
Why, tradeoff and connected operations
Kafka retained partitioned stream. Key events by the domain ordering key; replay and independent consumers motivate this choice. rows remain in the source database; a relay publishes after commit. Buffer independent producers and consumers, with bounded and replay semantics.
Tradeoff: Out-of-order or missed invalidations
Connected operations: Publish event; Consume work
Redis / Replicated Caches
Reject stale version
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: Stale reads until copies converge
Connected operations: Consume work; Pass validated input
Reader
Check current data
Why, tradeoff and connected operations
Isolate this operation so it can scale and fail independently from storage.
Tradeoff: Freshness check costs a lookup
Connected operations: Pass validated input
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 |
|---|---|
| Let source versions decide which update wins | Keeping version barriers uses memory. Rechecking the source gives stronger freshness but increases read cost and dependency on the source. |
| Repair missed or reordered updates | Keep delete/version evidence through the longest supported delayed fetch or replay. If history is missing, rebuild rather than guess. |
| What happens if a region fails? | Asynchronous propagation permits bounded staleness; forcing synchronous global invalidation increases latency and can reduce write availability. |
| Delete propagation and version | Longer barrier consumes memory; shortening it requires stronger bounds on stale work and a rebuild policy. |
Production scars & failure modes
Version 12 arrives before version 11 at one cache replica.
Look for: Record the highest applied version and invalidation backlog.
Recovery and invariant: Reject regressing updates, preserve versioned deletes and repair from authoritative state; message arrival order is not the data version.
| Component / failure | Impact | Recovery mechanism | Alternative / tradeoff |
|---|---|---|---|
| Primary failure / race | A read of version 7 starts before a write of version 8. The invalidation reaches the cache before the slow read fills it. What happens? | Reject the late version-7 fill against the version-8 floor. Deliver updates through durable / and reconcile missed events. | Version floors cost memory; alone does not close the race and stronger freshness may require checking the source. |
| Recovery follow-up | Let the expire while a very slow version-7 fetch is still running. State the supported request/replay horizon. | Reject the late version-7 fill against the version-8 floor. Deliver updates through durable / and reconcile missed events. | State the guarantee you relax and how you detect recovery. |
90-second interview summary
For write propagation, I would make the source-assigned version the authority and treat invalidation delivery as delayed, duplicated and potentially reordered. Each source transaction commits the new value/version and durable publication intent together.
A cache maintains a minimum acceptable version. Installing a refill or replacement compares that version and writes the value atomically at the cache owner. This prevents a slow version-7 read from reinstalling old data after version-8 invalidation has already arrived.
Deletes need the same protection: removing the cached value is not enough if an older refill can return later. A versioned deletion barrier remains through the supported stale-work and replay window. Event notifications speed convergence, while periodic repairs missed delivery.
I would test reordered updates, consumer restart, cache loss and a region delayed beyond retained history. Recovery either rebuilds the current source version/barrier or rejects unsupported stale input. Metrics include propagation age, regressing-update rejection and repair gaps. The tradeoff is extra per-key version/deletion state and more complex cache writes in exchange for bounded stale behavior; simply relying on event arrival time or a short leaves the late-fill race unresolved.
Explain it without looking
Explain let source versions decide which update wins
Reveal answer
The source assigns versions and each cache rejects older replacements.
Network arrival order can differ from the order in which the source committed changes.
Keeping version barriers uses memory. Rechecking the source gives stronger freshness but increases read cost and dependency on the source.
Explain repair missed or reordered updates
Reveal answer
Reject old fills and replay durable changes from the source.
A crash can happen between any two delivery steps; one missed notification cannot be the only record of a required update.
Keep delete/version evidence through the longest supported delayed fetch or replay. If history is missing, rebuild rather than guess.
Explain what happens if a region fails?
Reveal answer
Reject old updates even when they arrive late from another region.
The same late-fill race exists across regions with a larger delay window.
Asynchronous propagation permits bounded staleness; forcing synchronous global invalidation increases latency and can reduce write availability.
Explain delete propagation and version
Reveal answer
A deleted key needs a durable version barrier through the stale-replay window.
Deletes are state transitions, not simply opportunities to free cache memory.
Longer barrier consumes memory; shortening it requires stronger bounds on stale work and a rebuild policy.
Revision checklist
Revision checklist
- Reconstruct let source versions decide which update wins: The source assigns versions and each cache rejects older replacements.
- Reconstruct repair missed or reordered updates: Reject old fills and replay durable changes from the source.
- Reconstruct what happens if a region fails?: Reject old updates even when they arrive late from another region.
- Reconstruct delete propagation and version : A deleted key needs a durable version barrier through the stale-replay window.
- 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