Sharding medium
In a sharded architecture, what does the 'Scatter-Gather' query pattern imply for application performance?
- A It is an optimization that allows the database to aggregate data in the background without affecting live traffic.
- B It is a caching strategy where the application gathers data from multiple Redis instances before contacting the main database.
- C It occurs when a query does not include the 'Shard Key', forcing a central router to broadcast the query to every shard and wait for all of them to respond before merging the results.
- D It is a method used to migrate data between shards without locking the tables.
Answer: C. It occurs when a query does not include the 'Shard Key', forcing a central router to broadcast the query to every shard and wait for all of them to respond before merging the results.
Scatter-Gather is often called the 'tax' of sharding. Because the router doesn't know which shard holds the missing data, it must treat every shard as a potential match. This pattern suffers from 'Tail Latency'—the entire query is only as fast as the *slowest* individual shard in the cluster. To maintain high performance, developers should strive to include the Shard Key in every time-sensitive query to ensure the request is routed directly to a single machine (a 'Single-Shard Query').
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)?