Sharding hard
In a globally sharded system, if a network submarine cable is cut, isolating the US shards from the EU shards, and you must continue allowing both US and EU users to update their profiles, what must you sacrifice according to the CAP Theorem?
- A Availability: Both shards must go into read-only mode until the network link is physically restored.
- B Partition Tolerance: The system must be able to prevent the physical network cable from being cut in the first place.
- C Consistency (Linearizability): Users will successfully update their data, but the two regions will drift apart (Split-Brain), meaning they will not see each other's updates until the network is healed.
- D Storage Capacity: The shards must delete old data to make room for the extra metadata needed to track the network partition.
Answer: C. Consistency (Linearizability): Users will successfully update their data, but the two regions will drift apart (Split-Brain), meaning they will not see each other's updates until the network is healed.
You are choosing 'AP' (Availability + Partition Tolerance) over 'CP'. In an AP system, 'The Show Must Go On'. It is often better to have two slightly inconsistent databases than for the entire internet to go dark for all European users. The engineering challenge is then 'Partition Healing'—when the cable is repaired, the system must use complex techniques (like Merkle Trees or Vector Clocks) to synchronize the millions of divergent updates without losing data or creating permanent inconsistencies.
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)?