An eviction policy decides which entry a cache kicks out when its memory is used up.
A cache tries to answer all requests with the minimum number of database calls. It cannot predict what is asked next, so it picks an entry to kick out: the least recently used, the least frequently used, or FIFO.
A single eviction policy does not work at Facebook, because the access patterns of its objects are different. Facebook saw two types of entries:
- Long lived, evergreen entries. People keep using them from time to time, maybe for a day. Logos, ads and profile pictures are like this.
- Short lived entries. They are popular for a short period and never used again, like a list of 50 entries run through once.
Least recently used is good for the short lived entries and poor for the evergreen ones, which are used from time to time.
Kept together, the short lived objects kick out the evergreen ones. So the cache is split into two, and each part gets its own policy.