Interview › Databases & Caching
What is the difference between a write-through and write-behind cache regarding data loss?
Databases & Caching · Advanced level
Answer
Write-through updates cache and database synchronously, giving stronger consistency but higher write latency. Write-behind writes to cache first and flushes later, improving latency but risking data loss without durable buffering.
Technical explanation
Write-through favors consistency but couples success to both cache and database write paths.
Write-behind favors latency and burst absorption but can lose data before flush.
Write-behind needs durable queueing, idempotent workers, retries, DLQ, and reconciliation.
Hands-on example
Use write-through or direct DB transaction for inventory updates.
Use write-behind only for tolerable-loss events such as page-view counters.
If used: append to Kafka/SQS, update DB idempotently, monitor queue lag, and reconcile totals.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Databases & Caching interview questions
- What is Amazon RDS, and what does it manage for you versus self-managed databases?
- What database engines does RDS support?
- What is the difference between RDS and Aurora?
- What is Multi-AZ in RDS, and how does automatic failover work?
- How long does an RDS Multi-AZ failover typically take, and what triggers it?
- What is the difference between Multi-AZ and a read replica?
- When would you use a read replica, and can it become a standalone database?
- Can a read replica be in a different region, and why would you do that?