Memshare: a Dynamic Multi-tenant Memory Key-value Cache

Asaf Cidon, Daniel Rushton, Stephen M. Rumble, Ryan StutsmanarXiv 2016

Introduction

Modern web infrastructure relies heavily on DRAM-based key-value caches like Memcached to minimize latency. In multi-tenant environments, where multiple applications share a single cache server, the standard approach is static partitioning. This method assigns fixed memory slices to each application using slab allocators. However, static partitioning is inherently inefficient; it leads to "stranded" memory where idle applications hold RAM that could otherwise alleviate misses for applications experiencing traffic bursts. Memshare addresses this by introducing a log-structured cache that enables dynamic, fungible memory allocation.

System Architecture and Methods

Memshare replaces traditional slab-based allocation with a log-structured design, treating memory as a series of segments. This shift allows objects of any size to be appended to the log head, making memory segments easily reclaimable and reusable across different applications regardless of the previous object sizes stored there.

Memshare Architecture: The Arbiter manages allocations based on application needs, while the Cleaner handles segment compaction and eviction.

The system architecture consists of two primary components:

  1. The Arbiter: This component monitors per-application statistics and approximates hit-rate gradients to set new memory allocation targets. It uses "shadow queues"—metadata structures that track recently evicted keys—to identify which applications would benefit most from additional RAM.
  2. The Cleaner: Responsible for enforcing the Arbiter's allotments, the Cleaner relocates useful items to compact space and evicts less useful items to free up segments. It allows each tenant to define its own eviction policy (like LRU or LFU) via a ranking function.

To prevent underutilized data from hoarding resources, Memshare implements an idle tax. This mechanism reclaims memory from applications whose data hasn't been accessed for a long period, ensuring the cache remains fluid and responsive to active workloads.

Evaluation and Results

The authors evaluated Memshare using real-world traces from Memcachier and the YCSB benchmark. The results demonstrate that Memshare significantly outperforms static partitioning by allowing memory to flow dynamically to where it is most needed.

Comparison of Partitioned Slab vs. Shared Slab (Memshare) showing how dynamic cache occupancy reduces miss rates over time.

Key performance metrics include:

  • Hit Rate Improvement: On Memcachier traces, Memshare increased the combined hit rate from 84.7% to 90.8%, representing a 6.1% absolute gain.
  • Miss Reduction: This improvement resulted in a nearly 40% reduction in total cache misses, substantially decreasing the load on backend databases.
  • Efficiency: Even in single-tenant scenarios, Memshare's log-structured approach outperformed existing slab-based solutions by 2.37%.
  • Low Overhead: Despite the background cleaning and compaction, memory bandwidth usage remained below 10 MB/s, representing a negligible fraction of modern CPU capacity.

Conclusion

Memshare demonstrates that trading a small amount of CPU overhead for sophisticated memory management is a winning strategy for modern multi-tenant caches. By making memory fungible and dynamic, it eliminates the inefficiencies of static partitioning, providing a more robust and high-performance caching layer for cloud-scale applications.

Summary updated

Abstract

Web application performance is heavily reliant on the hit rate of memory-based caches. Current DRAM-based web caches statically partition their memory across multiple applications sharing the cache. This causes under utilization of memory which negatively impacts cache hit rates. We present Memshare, a novel web memory cache that dynamically manages memory across applications. Memshare provides a resource sharing model that guarantees private memory to different applications while dynamically allocating the remaining shared memory to optimize overall hit rate. Today's high cost of DRAM storage and the availability of high performance CPU and memory bandwidth, make web caches memory capacity bound. Memshare's log-structured design allows it to provide significantly higher hit rates and dynamically partition memory among applications at the expense of increased CPU and memory bandwidth consumption. In addition, Memshare allows applications to use their own eviction policy for their objects, independent of other applications. We implemented Memshare and ran it on a week-long trace from a commercial memcached provider. We demonstrate that Memshare increases the combined hit rate of the applications in the trace by an 6.1% (from 84.7% hit rate to 90.8% hit rate) and reduces the total number of misses by 39.7% without affecting system throughput or latency. Even for single-tenant applications, Memshare increases the average hit rate of the current state-of-the-art memory cache by an additional 2.7% on our real-world trace.
BibTeX
@misc{cidon2016memshare,
  author = {Asaf Cidon and Daniel Rushton and Stephen M. Rumble and Ryan Stutsman},
  title = {{Memshare: a Dynamic Multi-tenant Memory Key-value Cache}},
  year = {2016},
  eprint = {1610.08129},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1610.08129},
}
Figure