System Design
7. Caching ArchitectureAnimated
Least Frequently Used (LFU)
Evict the entry used the fewest times.
The idea
Counts how often each entry is used and removes the least popular.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- hit
- current request
A is missing: fetch it from the database and store it.
- step:
- 1
- hits:
- 0
1/22
Eviction policy: least frequently used.
Step by step
- 1Count accesses per entry
- 2Evict the lowest count
- 3Break ties by age
- 4Keep popular items
Where it is used
Stable popularity patterns.
Watch out for
Old popular items linger. Counts may need decay.