Sharding medium
Which sharding strategy is mathematically optimized for efficient 'Range Scans' (e.g., retrieving all records created between January and March)?
- A Hash-Based Sharding.
- B Consistent Hashing with Virtual Nodes.
- C Simple Modulo Sharding.
- D Range-Based Sharding.
Answer: D. Range-Based Sharding.
Range-Based sharding is specifically designed to keep contiguous data together on the same physical server. For example, if Shard A stores keys [1-100], a query for keys [20-50] only needs to contact one machine. In contrast, 'Hash-Based' sharding scatters keys randomly to ensure an even load. While Hashing prevents 'Hotspots', it forces the database to perform a 'Scatter-Gather' query across every single node in the cluster to satisfy a range request, significantly increasing network overhead and latency.
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)?
- In a sharded architecture, what does the 'Scatter-Gather' query pattern imply for application performance?