I have a collection which have size : 60 GB
I want to shard this collection. Shard key is hash index and unique.
I followed this document https://docs.mongodb.com/manual/reference/limits/#Sharding-Existing-Collection-Data-Size
Avg byte size of shard key values 56287232
maxCollectionSize is coming 9.28 GB
As maxCollectionSize and Actual collection size different is huge i am unable to get what chunk size should i use
Thanks for help
2 Answers 2
There should be no problem. Because you are using hashed sharding index (64bits), calculation goes:
16777216 (bytes)/8 (bytes) = 2097152 maxSplits
2097152 * (64MB/2)=67'108'864MB = 65'536GB = 64TB
So, you will get about 1000 chunks what is distributed evenly to all shards in the cluster.
As per MongoDB documentation Modify Chunk Size in a Sharded Cluster The default chunk size for a sharded cluster is 64
megabytes.
As MongoDB documentation here New in version 2.6
: MongoDB provides the mergeChunks
command to combine contiguous chunk ranges into a single chunk. See Merge Chunks in a Sharded Cluster for more information.
Note: Be careful when splitting data in a sharded collection to create new chunks. When you shard a collection that has existing data, MongoDB automatically creates chunks to evenly distribute the collection. To split data effectively in a sharded cluster you must consider the number of documents in a chunk and the average document size to create a uniform chunk size. When chunks have irregular sizes, shards may have an equal number of chunks but have very different data sizes. Avoid creating splits that lead to a collection with differently sized chunks.
For further your ref here