The ECE 4/599 Course Blog

Segcache: a memory-efficient and scalable in-memory key-value cache for small objects

by David Luo (leader), Nanda Velugoti (blogger), Eugene Cohen (Scribe), Rabecka Moffit, Benjamin Knutson

Introduction

Modern web applications use in-memory key-value caches such as Memcached and Redis to ensure fast response times and high throughput. However, these systems have some drawbacks, including high metadata overhead, inefficient expiration management, and challenges with scalability. This paper presents Segcache, a new caching solution that addresses these issues by reimagining the way objects are stored and managed.

Segcache takes a different approach. TTL-indexed segment chains group objects that have similar creation and expiration times, making it easier to expire and evict a bunch of data at the same time. Metadata sharing reduces per-object overhead down to just 5 bytes, a 91% reduction compared to Memcached, by merging the metadata into shared segment headers. Instead of evicting objects one by one, merge-based eviction removes entire segments, keeping the more frequently accessed data while still getting memory space back.

Segcache Design and Implementation

Figure 3

As illustrated in the figure above, Segcache consists of three main components:

  1. TTL Buckets: used for reclaiming expired objects.
  2. Object Store: used to store segments as a log.
  3. Hash table: used for object lookup.

Segcache is implemented as a storage module within the open-sourced Pelikan project. [5], [6]

Results

These optimizations lead to significant performance gains. Compared to existing caching systems, Segcache uses 22-60% less memory and compared to Memcached on a single thread, it delivers up to 40% better throughput. It also scales pretty well, achieving an 8x speedup over Memcached with 24 threads.

Figure 10

Discussion

Leader’s comment: Segcache doesn’t need to do a full-cache scan in order for it to remove expired objects, which helps improve its efficiency, but also reduces the overhead seen in traditional caching systems.

Class discussion

Figure 8

Conclusion

In conclusion, Segcache uses a TTL-indexed segment structured storage mechanism to achieve high throughput, high scalability and high memory efficiency when compared to the existing state-of-the-art research/production level solutions.

References

  1. Paper: https://www.usenix.org/system/files/nsdi21-yang.pdf
  2. Slides:https://www.usenix.org/system/files/nsdi21_slides_yang-juncheng.pdf
  3. Video: https://www.youtube.com/watch?v=s7YtO0rk9WM
  4. HyperCache: https://shbakram.github.io/assets/papers/honors-thesis-junming.pdf
  5. http://www.github.com/twitter/pelikan
  6. http://www.github.com/thesys-lab/segcache