Why Twitter's write-heavy systems pose new challenges

Explore how Twitter's write-heavy systems present unique challenges, as detailed in a 2020 Carnegie Mellon research paper. The blog post highlights the surprising impact of cache object quantity and size changes on system performance

This research paper from Carnegie Mellon in 2020, is an eye opener 👁️

It uses production log traces from Twitter to evaluate different caching strategies. The results are astounding.

Key Takeaways

1. Fitting more objects in a cache is more impactful than the choice of eviction policy

  • That means data compression and reducing cache metadata is more important than the choice made between LRU and FIFO algorithms.
  • The more objects you can stuff in a cache, the more performant it is.

2. Object sizes change over time

3. Object TTL (TIME TO LIVE) can be more important than cache eviction policy

  • Despite its importance, there are no good proven algorithms for evicting expired objects.

  • A full scan is inefficient, and algorithms like the timer wheel (explained at InterviewReady) don't work on all objects.

  • Again, we notice that some principles of Java's garbage collection can be applied here (especially the generational hypothesis). Do check out the videos mentioned above.

4. Not all workloads are read-heavy

  • Facebook has very read-heavy workloads, and Memcached is accordingly optimized for reads.

  • Twemcache has some write-heavy workloads too (about 35-40% of the queries result in write operations).

  • The result is a break of many expectations, like behavior changes in the TTL of objects and the number of times these objects are accessed.

  • Understandably, with these expectations breaking, the cache performance of write-heavy clusters isn't great.


Overall, this paper is a must-read. It breaks commonly held assumptions about caches.

We often expect caching algorithms to do well looking at their time complexity. But in reality, practical considerations supersede optimizations.

Resources

  1. Read the paper: A large-scale analysis of hundreds of in-memory cache clusters at Twitter.
  2. Check out our list of whitepapers worth reading.
  3. Our recorded whitepaper readings are available in the system design course.

Cheers!

P.S. Twitter calls its version of Memcache, "Twemcache". Just found it funny :p

Start Preparing for your Dream Job today!

The most comprehensive Interview prep platform ever built

Start Prep