Quick revision
The short answer
With {tenantId: 1} as the shard key, every document of the big tenant has the same key value, so they must all live in one chunk range that cannot be split below a single value, a jumbo chunk, and the shard holding it takes the tenant's 40 percent of traffic. The key has a high-frequency value, so it cannot spread the load. We fix it by refining the shard key with a suffix field, refineCollectionShardKey from MongoDB 4.4, for example to {tenantId: 1, orderId: 1}, or by resharding to a better key with reshardCollection from 5.0, which copies the data and needs capacity planning; if isolation is the goal, zones can pin the big tenant to dedicated shards.
What to remember
In this answer, we saw that with {tenantId: 1} all documents of one tenant share a single key value, so they form a jumbo chunk that cannot split or move, and the shard holding it absorbs the tenant's 40 percent of traffic. We refined the key with a suffix using refineCollectionShardKey, making sure the suffix is not monotonic so new writes spread too, considered reshardCollection for a full change with its capacity cost, and used zones when the big tenant should be isolated on dedicated shards.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
With {tenantId: 1} as the shard key, every document of the big tenant has the same key value, so they must all live in one chunk range that cannot be split below a single value, a jumbo chunk, and the shard holding it takes the tenant's 40 percent of traffic. The key has a high-frequency value, so it cannot spread the load. We fix it by refining the shard key with a suffix field, refineCollectionShardKey from MongoDB 4.4, for example to {tenantId: 1, orderId: 1}, or by resharding to a better key with reshardCollection from 5.0, which copies the data and needs capacity planning; if isolation is the goal, zones can pin the big tenant to dedicated shards.
Why this question is asked
Sharding by tenant is a natural choice for a multi-tenant product: every query includes the tenant, so every query is targeted, and each tenant's data stays together. It works until one tenant grows much faster than the others. Then the design that kept a tenant's data together also keeps all of that tenant's load together, on one machine. Interviewers ask this scenario because it tests whether we understand chunks and their limits, and whether we know the tools MongoDB now provides to change a shard key online. In this answer, we will recap chunks and why they split, see why this tenant cannot be split, refine the key, compare it with resharding, look at zones for isolation, and check that the fix actually spreads the writes.
1A Quick Recap: Chunks and Splitting
In ranged sharding, the shard key's value space is divided into chunks, contiguous ranges of key values, each owned by one shard. When a chunk grows too large, MongoDB splits it at a key value in the middle, and the balancer moves chunks between shards to even out the data. Splitting only works at a boundary between two different shard key values, because a chunk is defined by key values.
So a chunk can never be smaller than all the documents that share one shard key value. If a single value has a very large share of the documents, the chunk containing it cannot be split, and MongoDB marks it as a jumbo chunk. The balancer also cannot move a jumbo chunk normally, so it stays where it is.
2Why One Shard Is at 90 Percent CPU
Here the key is tenantId alone, and one tenant generates 40 percent of all traffic.
| Shard | Share of operations before | After a hashed orderId suffix |
|---|---|---|
| A | 20 percent | 33 percent |
| B | 70 percent, including all of tenant 17 | 34 percent |
| C | 10 percent | 33 percent |
Every order of tenant 17 has the same shard key value, 17, so all of them belong to the single range from 17 to 18. MongoDB cannot cut that range any finer, so the chunk is jumbo, it stays on shard B, and every read and write for tenant 17 lands there. Shard B runs at 90 percent CPU while A and C are lightly loaded. The underlying cause is the shard key's distribution: it has a value with very high frequency, so it cannot spread that value's load, no matter how many shards we add.
3Fix 1: Refine the Shard Key With a Suffix
From MongoDB 4.4 we can refine a shard key by adding fields at the end, without moving data. The existing prefix, tenantId, stays, so every query that targets a tenant still works, but now documents of one tenant have different shard key values and chunks can split inside the tenant.
Notice a subtle catch in the suffix. If orderId increases over time, then within tenant 17 all new orders still land in the tenant's last chunk, the one with the highest orderIds, so new writes for the tenant are again concentrated on one shard, even though the old data is spread. Reads of existing orders spread well, but inserts do not. To spread inserts too, the suffix should not be monotonic, for example a hashed field, {tenantId: 1, orderId: 'hashed'}, or a random or well-distributed identifier. Compound keys with one hashed field are supported from 4.4; check your version's rules for which positions may be hashed and whether refining to a hashed suffix is allowed, or use resharding for that change.
After refining, queries that include tenantId and orderId target one shard, and queries with only tenantId go to the shards holding that tenant's chunks, which for tenant 17 is now several shards, a reasonable trade.
4Fix 2: Reshard to a Better Key
If the key needs to change more than a suffix allows, MongoDB 5.0 added reshardCollection, which redistributes the collection to a completely new shard key while the application keeps reading and writing.
Resharding is a full copy. Each shard needs enough free disk space and spare CPU and I/O to hold and build the new distribution while still serving traffic, and it takes hours for large collections. So we plan capacity, run it in a quiet period, and monitor progress with the currentOp output for the resharding operation. Check your version's documentation for the exact space requirements and limits, since they have changed between releases.
5Zones for Isolation
Sometimes the goal is not even spreading but isolation: the big tenant pays for dedicated capacity, or we do not want it to affect everyone else. Zones let us pin a range of shard key values to specific shards.
- Is the problem a single key value?jumbo chunk in sh.statusYesShard key needs more granularityNoLook at other causes
- Can a suffix field fix it?refine is metadata onlyYesrefineCollectionShardKeyNoreshardCollection
- Should the tenant be isolated?cost and noisy-neighbour concernsYesAdd zones for dedicated shardsNoLet the balancer spread it
- Verify load per shardCPU, ops and chunk counts
4 steps in order. Play them, or step through them one at a time.
Combined with the refined key, tenant 17's data spreads across the two dedicated shards and nobody else's data lives there. Other tenants share the remaining shards. Zones are also useful for data residency, keeping a region's tenants on shards in that region.
6Follow-up questions
Why not just give shard B a bigger machine?
That buys time, but the tenant's load stays on one shard and grows with the tenant. The point of sharding is horizontal scaling, and a key that cannot split the largest tenant defeats it.
How would we have caught this earlier?
By checking shard key frequency when designing: if any single tenant could plausibly exceed one shard's share, the key needs a suffix from the start. Monitoring jumbo chunks and per-shard operation counts would also have warned us before CPU hit 90 percent.
Does refining the key change queries?
Queries that include tenantId still target the tenant's chunks, now possibly on several shards. Unique indexes and the application code are unchanged, though inserts must include the new suffix field, which every order already has.
7Conclusion
In this answer, we saw that with {tenantId: 1} all documents of one tenant share a single key value, so they form a jumbo chunk that cannot split or move, and the shard holding it absorbs the tenant's 40 percent of traffic. We refined the key with a suffix using refineCollectionShardKey, making sure the suffix is not monotonic so new writes spread too, considered reshardCollection for a full change with its capacity cost, and used zones when the big tenant should be isolated on dedicated shards.
Open with
The cause is the shard key's distribution. With tenantId alone, every document of the big tenant has the same key value, and chunks can only be split between different values.
Then, if they want more
So that tenant's data sits in one chunk that can't be split, a jumbo chunk, and the balancer can't move it normally. The shard holding it gets all of that tenant's forty percent of traffic, which is why one shard is at ninety percent while the others are idle. Adding shards wouldn't help.
The fix is to give the key more granularity inside a tenant. From 4.4 I can use refineCollectionShardKey to add a suffix, for example tenantId plus orderId, after creating the matching index. It's a metadata change, the jumbo chunk can then split at orderId boundaries and the balancer spreads it.
One catch: if orderId increases over time, new orders for that tenant still go to its last chunk, so I'd prefer a hashed or non-monotonic suffix. If the key needs a bigger change, reshardCollection from 5.0 moves data to a new key online, but it copies the whole collection, so I'd plan disk, CPU and timing.
And if the business wants that tenant isolated, zones can pin its key range to dedicated shards. Afterwards I'd verify CPU, operations and chunk counts per shard.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- MongoDB manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "One shard in a cluster is at 90 percent CPU while others are idle. The shard key is...": https://scrivio-interview-library.netlify.app/databases/mongodb/73f3f2b22b/