Sharding hard
How does 'Rendezvous Hashing' (HRW) differ from standard 'Consistent Hashing' in terms of implementation and performance?
- A Rendezvous hashing is only used for password encryption, while Consistent hashing is used for database routing.
- B Rendezvous hashing requires a central ring-topology map, whereas Consistent hashing is completely stateless.
- C Instead of a ring, Rendezvous hashing computes a hash for every pair of `(Key, ServerID)` and picks the server with the highest score. This ensures a more uniform distribution but requires $O(N)$ computation per request.
- D Rendezvous hashing is significantly faster because it uses simple modulo math instead of complex hash functions.
Answer: C. Instead of a ring, Rendezvous hashing computes a hash for every pair of `(Key, ServerID)` and picks the server with the highest score. This ensures a more uniform distribution but requires $O(N)$ computation per request.
HRW is a 'state-free' routing strategy. In Consistent Hashing, the client must keep a copy of the 'Ring' map to find the correct node. In HRW, the client only needs a list of the live Server IDs. For every query, it hashes the ID with the server name. This is extremely efficient for 'Proxy-less' load balancing where you don't want to maintain a complex shared topology. The downside is that as the cluster grows to thousands of servers, calculating thousands of hashes for every single database request becomes a significant CPU bottleneck for the application.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- In an E-Commerce platform, why might you choose to shard the `Orders` table by `user_id` rather than the more obvious `order_id`?
- In the context of database scaling, what is the fundamental difference between 'Vertical Partitioning' and 'Horizontal Partitioning' (Sharding)?
- If Shard A fails in a large cluster, and its incoming traffic is automatically re-routed to Shard B, what is the risk of a 'Cascading Failure'?
- In a standard 'Modulo Sharding' setup (`key % N`), what is the primary consequence of adding a new server to the cluster (increasing N from 10 to 11)?
- From an engineering perspective, when should you choose 'Vertical Scaling' (a bigger server) over 'Horizontal Scaling' (Sharding)?
- Which sharding strategy is mathematically optimized for efficient 'Range Scans' (e.g., retrieving all records created between January and March)?