> For the complete documentation index, see [llms.txt](https://xzhu0027.gitbook.io/blog/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xzhu0027.gitbook.io/blog/storage/index/distcache-provable-load-balancing-for-large-scale-storage-systems-with-distributed-caching.md).

# DistCache: provable load balancing for large-scale storage systems with distributed caching

https\://www\.usenix.org/conference/fast19/presentation/liu

### Motivation

The last paper shows that caching O(nlogn) hottest objects is enough to balance n storage nodes, regardless of the query distribution. **However, it also requires that the throughput needs to be no smaller than the aggregate throughput of the storage nodes not to become the system bottleneck.**&#x20;

![](https://1271107977-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LkwjM9iFxyVX0PINZ87%2F-M1lNsa3Hg9TlWFe0AQY%2F-M1lTiNFNe_vUQXUQpQm%2FScreen%20Shot%202020-03-06%20at%203.12.47%20PM.png?alt=media\&token=f2bc872a-f8a0-4931-a94a-ec8e5475e02b)

As a result, the small cache solution cannot scale out to multiple clusters. However, if we only put a cache in front of each clusters, the load between clusters can be unbalanced. One way to mitigate this issue is to use multiple upper-layer nodes, but it brings the question of how to allocate hot objects to the upper-layer cache nodes. Traditional cache allocation mechanisms are suboptimal. Cache partition has low overhead for cache coherence, but cannot increase the cache throughput linearly with the number of cache nodes; cache replication achieves the opposite.

Thus, the main challenges are to carefully partition and replicate the hot objects, in order to (i) avoid load imbalance between upper-layer cache nodes, and to (ii) reduce the overhead for cache coherence.

### DistCache

![](https://1271107977-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LkwjM9iFxyVX0PINZ87%2F-M1lNsa3Hg9TlWFe0AQY%2F-M1lag8HhkI9NNVt6_FB%2FScreen%20Shot%202020-03-06%20at%203.47.39%20PM.png?alt=media\&token=60d69cfc-9978-4a55-8ea7-95df9a281e14)

**The key ideas of DistCache are 1) use independent hash functions to partition hot objects in different layers. 2) Use the power-of-two-choices to route queries. e.g., route Get(A) to either C1 or C3 based on cache load.**&#x20;

DisCache's lower-layer cache nodes primarily guarantee intra-cluster load balancing and each cluster appears as one "big server". The upper-layer cache nodes are primarily for inter-cluster load balancing, and uses a different hash function for partitioning. The independent hash functions guarantee that if one cache node in a layer is overloaded by receiving too many queries to its cached objects, the set of hot objects would be distributed to multiple cache nodes in another layer with high probability.&#x20;

DistCache uses an efficient, distributed, online solution based on the power-of-two-choices to route queries. Specifically, the sender of a query only needs to look at the loads of the cache nodes that cache the queried object, and sends the query to the less-loaded node.&#x20;
