Skip to content
StackDecode
System Design
7. Caching ArchitectureAnimated

Write-Behind Cache

Write to the cache first, the database later.

The idea

Writes are acknowledged quickly and flushed to the database asynchronously in batches.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

RequestL1 in-processL2 RedisDatabase
  • client
  • gateway / proxy
  • service
  • cache
  • data store
  • queue / stream

Check the in-process cache: nanoseconds.

step:
1/4
at:
Request
1/10

The green dot is a request moving through the system.

Step by step

  1. 1Write to the cache
  2. 2Acknowledge immediately
  3. 3Queue the change
  4. 4Flush to the database later

Where it is used

Write-heavy workloads.

Watch out for

Data loss if the cache fails before flushing.

Related