Write-back vs write-through
Write-back confirms a write as soon as the cache has it and sends it to the database later. Write-through confirms only after the database has the write. When the cache crashes for 2 s, write-back loses confirmed writes and write-through loses none.
1,600 keys · hit 81% · mean 3.2 ms
Backup every 60 minutes · RPO 60 minutes · RTO 11 hours at 100 Mbps
Case 1
Half of the requests write. Each write takes 300 ms to reach the database, and the cache crashes for 2 s at 0:10. No confirmed write may be lost.
| Measure | Goal | Write-back | Write-through |
|---|---|---|---|
| Lost writes | none | 15 Fail | 0 Pass |
| Stale reads | none | 0 Pass | 0 Pass |
| Monthly cost | 8 USD/mo | 8 USD/mo | |
| p99 latency | 368 ms | 372 ms | |
| Error rate | 6.7% | 6.7% |