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.
The system architecture consists of two primary components:
- 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.
- 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.
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