Software Design

Write-Through vs Write-Behind Caching Patterns

UML Sequence Diagrams · made in Skemio

Sequence diagram of Write-Behind caching showing asynchronous queue batching to a database.
Sequence diagram of Write-Behind caching showing asynchronous queue batching to a database.

What it shows

  • Write-through commits to DB synchronously, preventing data loss on crash.
  • Write-behind enqueues writes in memory, delivering sub-millisecond ACKs.
  • Write-behind risks dropping uncommitted records if the cache node fails.

The takeaway

Pick write-through for strong durability, and write-behind when maximizing raw write throughput.

More uml sequence diagrams