I have a MongoDB (v8.0.9) sharded cluster running in Kubernetes with the following setup:
- 3 shards, each with 2 replicas
- An empty collection was created with a hashed shard key (over a UUID field)
- Sharding was enabled using:
sh.enableSharding("db") sh.shardCollection("db.collection", { shardkey: "hashed" }) - The balancer was started:
sh.startBalancer() - I started importing data at a rate of about 2,500 documents per second
- I stopped the import after reaching approximately 716 million documents
Data distribution is perfect (about 33.3% of data on each shard), but the problem is that there are only 10 chunks in total. Here is the output from the chunk distribution (after 2 days after data import):
Shard-0
{
data: '884.5GiB',
docs: 238,840,277,
chunks: 1,
'estimated data per chunk': '884.5GiB',
'estimated docs per chunk': 238,840,277
}
Shard-1
{
data: '884.4GiB',
docs: 238,813,353,
chunks: 4,
'estimated data per chunk': '221.1GiB',
'estimated docs per chunk': 59,703,338
}
Shard-2
{
data: '884.54GiB',
docs: 238,851,801,
chunks: 5,
'estimated data per chunk': '176.9GiB',
'estimated docs per chunk': 47,770,360
}
My question:
Why are there only 10 chunks in total, even though the collection contains over 700 million documents and nearly 900 GiB of data per shard?
Additional info:
- The balancer is running.
- The collection was empty before import.
- The shard key is a hashed UUID field.
- chunksize: 128
What could be causing the low number of chunks? Shouldn’t there be many more chunks given the data volume?
What I tried:
- I attempted to manually split the chunks using the sh.splitFind() method.
- After executing the splits, the chunks were indeed split as expected.
- However, after a few minutes, the chunks reverted back to their previous state (i.e., the splits were undone).
Update (2025-05-27):
I continued with testing and added 3 new shards to the cluster (so now there are 6 shards in total). The balancer was enabled and running. However, I noticed that after adding the new shards, the data was not automatically redistributed to the new shards—everything remained on the original 3 shards, and the chunk distribution did not change.
My questions:
- What is the best approach to trigger data rebalancing after adding new shards to an existing cluster?
- Is it effective for the balancer to work with such large chunks (e.g., ~884 GB per chunk), or should I try to split them into smaller chunks first?
- Is there a recommended way to force or accelerate the redistribution of data to the new shards in this scenario?
Thank you for any insights!