System Design
7. Caching ArchitectureAnimated
Write-Through Cache
Writes go to the cache and database together.
The idea
Each write updates the cache and then the database synchronously, keeping them consistent.
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
- 1App writes to the cache
- 2The cache writes to the database
- 3Both are updated
- 4Acknowledge
Where it is used
Data that is read soon after writing.
Watch out for
Slower writes, and cache fills with rarely read data.