09 / 15

What are zones in sharding?

Zone is a grouping of documents based on ranges of shard key values for a given sharded collection. zones are logical groupings of shards based on specific criteria, such as geographical location or data type. Each shard in the sharded cluster can be in one or more zones. In a balanced cluster, MongoDB directs reads and writes for a zone only to those shards inside that zone. See the Zones manual page for more information.

  1. 1

    Geographic Zones: Data is distributed into shards based on regions, ensuring users in Asia primarily interact with servers in Asia, minimizing access delays.

  2. 2

    Functional Zones: Shards are grouped based on application-specific logic, such as separating user data from transaction data.

Difficulty: 5/10
Topics: shard zones, data placement, balancer

Scenario Questions

0-2 years experience
  1. 1

    If you need to ensure that all orders from Europe are stored on a specific shard, how would you configure zones in MongoDB?

  2. 2

    What happens when you add a new zone range that overlaps with an existing one? How does the balancer react?

  3. 3

    Suppose you have a collection sharded on 'userId' and you want to keep IDs 0‑999 on shard A and the rest on shard B. Walk me through the steps to set that up.

2-5 years experience
  1. 1

    Your application is experiencing latency spikes because the balancer is moving chunks across zones during peak hours. How would you diagnose and mitigate the issue?

  2. 2

    We decided to add a new data‑center in Asia and want to create a zone for that region. What trade‑offs do you consider when assigning chunk ranges to the new shard?

  3. 3

    During a deployment, you notice that a zone you defined is not receiving any chunks. What could cause this and how would you fix it?

5-8 years experience
  1. 1

    Design a strategy to automatically rebalance zones when a shard becomes overloaded, ensuring minimal impact on read/write latency.

  2. 2

    Explain how you would handle a scenario where regulatory requirements force you to move a specific key range from one zone to another without downtime.

  3. 3

    What are the performance implications of having many small zones versus a few large zones, and how would you decide the granularity?

8+ years experience
  1. 1

    At a company with multiple microservices each owning different data domains, how would you architect zone definitions to support cross‑service data locality while allowing independent team ownership?

  2. 2

    If you need to migrate a legacy monolithic MongoDB deployment to a sharded cluster with zones, outline the migration plan, including data back‑fill, zone rollout, and rollback considerations.

  3. 3

    Discuss the long‑term operational challenges of maintaining zone configurations as the business evolves, and propose governance processes to keep them aligned.

Follow-up Questions

  • Can you walk me through how the balancer decides which chunk to move for a zone?
  • What metrics would you watch to know a zone is becoming imbalanced?
  • How would you test your zone configuration before rolling it out to production?