[SERVER-13524] Why MongoDB starts to split before 64MB? Created: 09/Apr/14  Updated: 10/Dec/14  Resolved: 29/Apr/14

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: None

Type: Question Priority: Minor - P4
Reporter: Maxime FOUILLEUL Assignee: Ramon Fernandez Marina
Resolution: Done Votes: 0
Labels: chunkSize, shard, split
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

MongoDB 2.4 and MongoDB 2.6


Participants:

 Description   

I'm testing the MongoDB Sharding with a Sharded Collection and a forloop to insert arround some documents to see how splitting and moving works.

After 10K documents MongoDB has split my collection in 3 chunks, well before 64Mb (the default chunkSize):

mongos> db.users.getShardDistribution()

Shard rs0 at rs0/mongod00.local.net:2100,mongod01.local.net:2101
data : 1.06MiB docs : 10000 chunks : 3
estimated data per chunk : 364KiB
estimated docs per chunk : 3333

Totals
data : 1.06MiB docs : 10000 chunks : 3
Shard rs0 contains 100% data, 100% docs in cluster, avg obj size on shard : 112B

It's not a problem but with this, I don't understant the interest of the chunkSize parameter.



 Comments   
Comment by Ramon Fernandez Marina [ 29/Apr/14 ]

Hi Maxime,

I believe Randolph's reply answers your question so we're closing this issue. Feel free to re-open if you need further clarification.

Regards,
Ramón.

Comment by Randolph Tan [ 09/Apr/14 ]

Mongos tries to perform splits aggressively early on when there are only a few chunks in the sharded collection. The basic idea is to start distributing the chunks across the cluster early on while there isn't much data to move. If you are interested in the exact formula used, you can check it out here:

https://github.com/mongodb/mongo/blob/r2.6.0-rc3/src/mongo/s/chunk.cpp#L1427-1449

Generated at Thu Feb 08 03:32:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.