System Design
7. Caching ArchitectureAnimated
Cache-Aside Pattern
The application loads data into the cache on demand.
The idea
The app checks the cache, on a miss it reads from the database and populates the cache.
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
- 1Read the cache
- 2On miss read the database
- 3Store the result in the cache
- 4Return
Where it is used
The most common pattern.
Watch out for
Stale data after writes unless entries are invalidated.