← Lessons

quiz vs the machine

Gold1450

System Design

The Write Back Cache

Acknowledging writes from the cache and flushing to the database later for speed.

5 min read · core · beat Gold to climb

What it is

A write back cache, also called write behind, accepts a write into the cache and acknowledges it immediately. The database is updated asynchronously a short time later, often after batching several writes together.

Why it is fast

  • The slow database write is removed from the critical path.
  • Repeated writes to the same key can be coalesced into one database update.
  • Bursts of writes are smoothed into steady background flushes.

The big risk

If the cache node crashes before a dirty entry is flushed, that write is lost forever. Mitigations include replication, durable write logs, and short flush intervals, but the data still lives briefly only in the cache.

When to use it

Write back suits high write throughput where occasional loss is tolerable, such as metrics, counters, or analytics buffers. It is a poor fit for money or orders that demand durability.

Key idea

Write back trades durability for throughput by buffering writes in the cache and flushing them to the database in the background.

Check yourself

Answer to earn rating on the learn ladder.

1. What is the central risk of a write back cache?

2. Why is write back faster than write through?