Sharding easy
In a distributed database, what is the role of a 'Shard Key'?
- A It is the cryptographic key used to secure data at rest on each disk.
- B It is the primary key used to identify a specific shard in the cloud provider's console.
- C It is the specific attribute used by the database to determine which shard a particular row belongs to.
- D It is the unique password required to connect to the database cluster.
Answer: C. It is the specific attribute used by the database to determine which shard a particular row belongs to.
The 'Shard Key' is the critical input parameter for the routing logic. For example, if you shard by `user_id`, the system uses that value to calculate which server holds that user's data. Choosing a bad shard key (one that isn't evenly distributed) is the most common cause of performance failures in partitioned systems, leading to 'Hotspots' where one server is overwhelmed while others remain idle.
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)?