TL;DR
AnchorHash is a new consistent hashing algorithm that finally breaks the trade-off between consistency and scalability. By leveraging a clever history-tracking mechanism and a tiny memory footprint (just 16 bytes per resource), it achieves millions of lookups per second even when scaling to 100 million resources.
What Problem Does This Paper Address?
Consistent hashing (CH) is the backbone of modern distributed systems, used for everything from load balancing TCP flows in datacenters to distributed storage. The goal is simple: map keys to resources such that the load is balanced and, if a resource is added or removed, only the minimum number of keys are remapped (a property called minimal disruption).
However, existing solutions force engineers to pick their poison:
- Ring Hashing: Offers good consistency but suffers from high memory usage and slow lookups as the system grows.
- Highest-Random-Weight (HRW): Excellent balance and low memory, but the computational cost of lookups is too high for high-speed networking.
- MaglevHash: Very fast lookups, but it isn't "fully" consistent (it can move keys unnecessarily) and its massive lookup tables lead to performance degradation at scale due to cache misses.
AnchorHash aims to provide the "holy grail": full consistency, perfect balance, high lookup rates, low memory footprint, and near-instant update times.
Methods
The core innovation of AnchorHash is its iterative hashing approach combined with a LIFO (Last-In, First-Out) stack of removed resources.
- The Anchor: The algorithm starts with a fixed set of possible buckets called the "Anchor."
- Iterative Hashing: To find a bucket for a key, AnchorHash first hashes the key across the entire Anchor. If the resulting bucket is currently active (in the "working set"), the process ends. If the bucket was previously removed, the algorithm "rehashes" the key into the set of buckets that were active at the moment that specific bucket was removed.
- Minimal Memory Implementation: While the basic idea requires storing the history of every removal, the authors developed a highly optimized implementation. Instead of storing full sets of buckets for every removal, they use a "Successor" array. This array tracks which bucket replaced a removed one. By tracing through these successors, the algorithm can reconstruct the necessary history using only $O(a)$ memory, where $a$ is the total number of resources.
Datasets
The authors evaluated AnchorHash using two primary methods:
- Synthetic Data: 64-bit randomly generated keys were used to test balance, lookup rates, and scalability up to 100 million resources.
- Real-World Trace: A backbone router trace from CAIDA (Center for Applied Internet Data Analysis) was used to verify performance on actual network traffic patterns.
Key Insights and Ideas
- Consistency through History: Unlike stateless algorithms, AnchorHash uses the order of resource removals to maintain full consistency. Because it can "undo" the last removal perfectly, adding a resource back simply restores the previous state without moving unrelated keys.
- Logarithmic Complexity: A major theoretical finding is that the number of hash computations required for a lookup depends on the fraction of failed resources, not their absolute number. Even if 50% of resources fail, a lookup only requires about 1.69 hash computations on average.
- Cache Efficiency is King: At massive scales (millions of resources), memory footprint determines speed. Because AnchorHash fits into a much smaller memory space than MaglevHash, it avoids expensive L3 cache misses, allowing it to maintain high throughput where other algorithms slow down.
Key Results
- Scalability: AnchorHash successfully scaled to 100 million resources on a single core.
- Throughput: It achieved a lookup rate of over 15 million keys per second.
- Memory Footprint: It requires only 16 bytes per resource. For a million resources, this is just 16 MB, compared to the 400+ MB required by MaglevHash to achieve similar balance.
- Update Speed: Resource additions and removals are processed in nanoseconds, regardless of system size. In contrast, MaglevHash can take several seconds to update its tables when dealing with $10^5$ resources.
Limitations and Future Work
The primary limitation of AnchorHash is that it is stateful. In a distributed environment with multiple dispatchers (like multiple load balancers), all dispatchers must agree on the exact order in which resources were removed (the content of the stack $R$). While the communication overhead for this agreement is small (it only happens when a resource status changes), it is a requirement that stateless algorithms like HRW do not have.
The authors suggest that future work could explore extending AnchorHash to maintain consistency in environments where dispatchers might not perfectly agree on the order of removals.
Summary updated