15. Sharding
Interview questions
Interview questions (with the counter-questions you'll get)
Q1. What is sharding, and when would you do it?
They're testing: knowing it's a last resort with real costs.
Think about your answer first, then open it.
Q2. How do you choose a shard key?
They're testing: the single most important decision.
Think about your answer first, then open it.
Q3. Range vs hash sharding?
They're testing: trade-offs.
Think about your answer first, then open it.
Q4. What causes hot shards, and how do you fix them?
They're testing: operational experience.
Think about your answer first, then open it.
Q5. How do you reshard without downtime?
They're testing: practical migration knowledge.
Think about your answer first, then open it.
Q6. How do you handle queries that don't include the shard key?
They're testing: cross-shard strategies.
Think about your answer first, then open it.
Q7. How do you enforce a unique email when users are sharded by ID?
They're testing: a classic gotcha.
Think about your answer first, then open it.
Q8. How do you do joins and transactions across shards?
They're testing: knowing what sharding takes away.
Think about your answer first, then open it.
Q9. How do sharding and replication combine?
They're testing: a full picture.
Think about your answer first, then open it.
Q10. How does a request know which shard to go to?
They're testing: routing options.
Think about your answer first, then open it.