Sharding easy
Does 'Sharding' a database automatically protect the system against a 'Single Point of Failure' (SPOF)?
- A Yes, because the data is now spread across multiple servers, making the system naturally indestructible.
- B No. Sharding only scales capacity. If Shard 1 fails and has no 'Read Replica', all the data held on that specific node becomes immediately unavailable to the entire system.
- C Yes, because every shard automatically maintains a mirror copy of all other shards in the cluster.
- D Only if the database is configured to use the UDP protocol instead of TCP.
Answer: B. No. Sharding only scales capacity. If Shard 1 fails and has no 'Read Replica', all the data held on that specific node becomes immediately unavailable to the entire system.
It is critical to distinguish between 'Sharding' (splitting data for scale) and 'Replication' (copying data for safety). A robust production architecture uses both: you shard the data into 10 groups, and then you replicate each group to 3 different nodes. Without replication, sharding actually *increases* the risk of failure; if even one of your 10 shards goes down, your entire application will likely experience errors when trying to reach that specific subset of users.
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)?