06 / 15

What is Shard?

Difficulty: 6/10
shard key selection, chunk distribution, balancer behavior

A shard is a horizontal partition of data in a database. It is essentially a subset of your data stored across multiple servers.

Scenario Questions

0-2 years experience

  1. 1We need to store rapidly growing user profiles. How would you enable sharding for this collection, and which field would you pick as the shard key?
  2. 2If you insert a document whose shard key value falls outside any existing chunk range, what does MongoDB do?
  3. 3When a query filters only on a non‑shard‑key field, how does MongoDB route that query in a sharded cluster?

2-5 years experience

  1. 1After adding a new shard, some reads became slower. Walk me through how you’d diagnose the issue and which sharding components you’d examine.
  2. 2Our app started throwing 'StaleShardVersion' errors after a recent chunk migration. Explain why this occurs and how you’d fix it.
  3. 3Given a compound shard key {region, userId}, what trade‑offs does this key introduce for typical read and write patterns?

5-8 years experience

  1. 1Design a sharding strategy for a multi‑tenant SaaS platform that stores both transactional and analytical data, addressing data isolation, hot‑spot avoidance, and rebalancing impact.
  2. 2A particular shard is becoming a hotspot because the shard key distribution is skewed. What mitigation techniques would you apply at the system level?
  3. 3Compare using a hashed shard key versus a ranged shard key in terms of query performance, balancing, and when you’d choose each.

8+ years experience

  1. 1We’re migrating a legacy monolithic MongoDB deployment to a globally distributed sharded architecture across three data centers. Outline the architectural considerations, migration steps, and operational safeguards you’d put in place to ensure continuity and low latency.
  2. 2How would you establish a cross‑team governance model for shard‑key selection and chunk‑migration policies to prevent future performance regressions in a large organization?

Follow-up Questions

  • Can you describe what happens during a chunk migration?
  • Why is choosing the right shard key so critical?
  • How does the balancer decide when to move chunks?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.