Cachingwrite-back cachewrite-behindwrite back

Write-behind cache

Definition

A write-behind (write-back) cache acknowledges a write after updating the cache and persists it to the backing store asynchronously, often coalescing and batching several updates.

In practice

Write latency drops to the cost of a cache write, bursts are smoothed into steady database load, and repeated updates to the same key collapse into one database write. It suits counters, metrics and other high-frequency updates where the latest value matters more than each step.

The database trails the cache by the flush backlog, so other readers of the database see old data. If the cache node crashes before flushing, acknowledged writes are lost unless the cache itself is replicated or persisted. Ordering, retries of failed flushes and conflicts with direct database writes all need explicit handling.

Example

View counters are incremented in Redis at 20,000 writes per second and flushed every 5 seconds as one batched UPDATE per article, cutting database writes to a few hundred per flush.