Sharding easy
In 'Range-Based' sharding (e.g., Shard A stores users with names A-M, Shard B stores names N-Z), what is a significant operational risk?
- A It requires an expensive lookup service for every single query.
- B It makes it impossible to perform range queries efficiently.
- C It often leads to 'Hotspots' if the data distribution is non-uniform (e.g., more users having names starting with 'S' than 'X').
- D It cannot be used with integer-based ID columns.
Answer: C. It often leads to 'Hotspots' if the data distribution is non-uniform (e.g., more users having names starting with 'S' than 'X').
While Range-Based sharding is excellent for specific types of queries (like scanning all orders for a specific month), it is highly vulnerable to uneven load. If your app is sharded by a timestamp, every single new write will hit the 'current time' shard, causing a massive bottle-neck while older shards sit idle. This is why many high-write applications prefer 'Hash-Based' sharding, which effectively randomizes data placement to ensure an even load across all servers.
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)?