Sharding medium
What is the primary benefit of 'Hierarchical' or 'Multi-Level' sharding in a global-scale application?
- A It combines 'Data Locality' (by first sharding by Region for speed) with 'Scalability' (by then sub-sharding by UserID within that region for load balancing).
- B It allows the system to support multiple different backup strategies on the same server cluster.
- C It focuses solely on sharding the database indexes rather than the actual data records to save CPU time.
- D It eliminates the need for any physical servers by virtualizing the database across multiple cloud providers.
Answer: A. It combines 'Data Locality' (by first sharding by Region for speed) with 'Scalability' (by then sub-sharding by UserID within that region for load balancing).
Hierarchical sharding is used by the world's largest apps. You first partition by a high-level key like `Country` or `Continent` to ensure a US user's data isn't being stored in Australia (preventing 300ms of speed-of-light latency). Once inside that region, you apply a second level of sharding (like `user_id % 10`) to distribute that region's millions of users across many regional servers. This ensures the app is both globally fast and infinitely scalable within each region.
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)?