Sharding easy
What is the primary function of a 'Sharding Proxy' or 'Routing Tier' in a distributed database system?
- A To compress data before it is written to the disk to save on storage costs.
- B To handle the encryption and decryption of every database packet to ensure security.
- C To act as a middleman that intercepts application queries and routes them to the correct shard, shielding the application from the cluster's complexity.
- D To perform automated daily backups and disaster recovery simulations.
Answer: C. To act as a middleman that intercepts application queries and routes them to the correct shard, shielding the application from the cluster's complexity.
Using a proxy (like Mongos for MongoDB or Vitess for MySQL) simplifies the application code—the developer writes queries as if they were talking to a single machine. The proxy handles the logic of 'Where is this User?' or 'Which 5 shards do I need to query for this report?'. While this makes the system easier to scale, the proxy itself adds an extra 'Network Hop' to every request, which can slightly increase the overall response time (latency).
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)?