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.
- 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
- 1Write to the cache
- 2Acknowledge immediately
- 3Queue the change
- 4Flush to the database later
Where it is used
Write-heavy workloads.
Watch out for
Data loss if the cache fails before flushing.