Skip to content
StackDecode
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.

request streamABFBFADADADFAADAACBDAFcache (4 slots)Aused 1xMISS A is fetched from the databasehit rate 0% (0 of 1)
  • 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

  1. 1Count accesses per entry
  2. 2Evict the lowest count
  3. 3Break ties by age
  4. 4Keep popular items

Where it is used

Stable popularity patterns.

Watch out for

Old popular items linger. Counts may need decay.

Related