I have two shards in the cluster, data distribution is even on the shards, but the problem is that, data is inserted into one chunk per shard, beside the reason that each chunk is bigger than default size(64MB).
I know, that this 64 MB is compressed size of data on the disk, but anyways, compressed data is bigger than this too.
When I insert data, it creates several quantity of chunks, but after that, balancer unites them into 1 chunk per shard.
Also tried manually splitting, got evenly split chunks, but still, balancer merged them after a few minutes.
This sounds like expected behavior, especially if the balancer sees a reason to merge for better balance, or if it thinks the chunks are too small.
A few things you can check:
Are the chunks actually jumbo?
Even if they’re larger than 64MB compressed, MongoDB won’t consider them jumbo unless a split is attempted and fails due to a lack of a split point (e.g., poor shard key choice).
You can check with: db.collection.getShardDistribution()
MongoDB sometimes joins chunks back together if they’re on the same shard, were split recently, and aren’t too big when combined. This usually happens after new data is added and small chunks are created temporarily.
Check balancer.mergeChunks setting:
In MongoDB 8.0+, mergeChunks is enabled by default. You can disable automatic merging with:
sh.setBalancerState(false)
sh.disableAutoSplit()
sh.disableAutoMerge()
Or just: sh.setAutoMerge(false)
Shard key choice matters:
If your shard key has low cardinality or doesn’t grow with inserts, MongoDB may struggle to split effectively. Make sure you’re using a high-cardinality, insert-friendly shard key (e.g., something like a hashed _id or a field with good distribution).
If the manual splits are getting reversed by the balancer, try disabling autoMerge temporarily and observe behavior. That usually helps confirm if it’s due to the balancer logic or something shard-key related.