Sharding hard
In the implementation of Consistent Hashing, what specific architectural problem do 'Virtual Nodes' (VNodes) solve?
- A They allow a single physical server to run multiple database engine processes simultaneously to utilize all CPU cores.
- B They ensure that all traffic between shards is encrypted using separate session keys for each virtual partition.
- C They minimize the network hop count by keeping a copy of the routing table in every physical node's L3 cache.
- D They enable uniform load distribution by breaking the hash ring into thousands of tiny segments, accounting for servers with varying hardware capacities.
Answer: D. They enable uniform load distribution by breaking the hash ring into thousands of tiny segments, accounting for servers with varying hardware capacities.
In a simple hash ring with only 3 physical nodes, one node might randomly end up responsible for 60% of the ring's keys simply due to bad luck in hash placement. 'Virtual Nodes' solve this by mapping each physical server to hundreds of random points on the ring. This 'Statistical Multiplexing' ensures that even with a few servers, the probability of an uneven load is extremely low. Furthermore, it allows for 'Weighting': a powerful server can be assigned 1,000 VNodes while a weaker server gets only 100, ensuring each machine is loaded proportionally to its CPU and RAM capacity.
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)?