Summary

Write-through writes data to cache and backing store synchronously. Write-back writes to cache first and persists later.

Interview Points

  • Write-through is safer and simpler but adds write latency.
  • Write-back is faster for writes but risks data loss and complexity.
  • Write-back needs durable queues, flushing, retries, and failure handling.
  • Write-around skips cache on write and fills on read.
  • Choose based on durability, latency, and read/write patterns.

2-3 Minute Interview Script

“In a write-through cache, every write updates both the cache and the database before success is returned. That keeps cache and storage consistent, but writes are slower.

In a write-back cache, the write lands in the cache first and is persisted asynchronously. That can improve write latency and absorb bursts, but it introduces durability risk if the cache fails before flushing.

For critical data, I prefer write-through or a durable write path. For high-volume less-critical data, write-back can work if backed by persistence, retries, and monitoring.

In an interview, I would say write-through optimizes correctness and simplicity, while write-back optimizes write performance at the cost of operational complexity.”

Follow-Ups

  • What happens if the cache crashes?
  • How do you avoid stale reads?