Sharding easy
In a 'Client-Side' sharding architecture, which component is responsible for determining the correct database node to contact?
- A An external hardware Load Balancer sitting in front of the database cluster.
- B The database server itself, which automatically redirects the request.
- C A centralized 'Proxy' server that handles all incoming traffic.
- D The Application Code or Database Driver, which calculates the route using a local configuration map before sending the request.
Answer: D. The Application Code or Database Driver, which calculates the route using a local configuration map before sending the request.
Client-Side sharding is the simplest way to implement a distributed system because it requires no specialized middle-ware. The application knows the algorithm (e.g., `user_id % 4`) and connects directly to the correct server. While this removes the performance 'bottleneck' of a central proxy, it is harder to manage; if you add a new database server, you must update the configuration across every single instance of your application simultaneously.
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)?