Maximum number of shards a collection can be horizontally distributed?

According to this:

“You can set the number of shards to deploy with the sharded cluster. Your cluster can have between 1 and 50 shards, inclusive.”

But according to MongoDB employee:

“I’m not aware of a specific limit on number of shards. For a similar discussion on limits, please see my response on Database and collection limitations - #2 by Stennie 108.”

and:

“MongoDB offers horizontal scale-out using sharding: While a single ‘Replica Set’ (aka a shard in a sharded cluster) cannot exceed 4TB of physical storage, you can use as many shards as you want in your MongoDB Atlas sharded cluster.”

Please resolve the contradiction or my mis understanding?

Hi. @Big_Cat_Public_Safety_Act :smiley:

I also knew that there was no limit to the number of shards.
However, looking at the 50 restrictions in the atlas manual, isn’t there no limit in the on-prem environment, and isn’t there a limit in the atlas environment?

@Kim_Hakseon

The last quote:

“you can use as many shards as you want in your MongoDB Atlas sharded cluster.”

So this is wrong?

Or is it that the number of shards that can be automatically added at the same time as the initial sharded cluster setting(sh.shardCollection()) is 1-50, and then manually add more through sh.addShard()?

It’s as if it’s below. (Explained with the repl command for feeling)

rs.initiate({members:[<1>,<2>,<3>, …, <50>]})
rs.add(<51>)
rs.add(<52>)

Would be great if a source of authority can confirm or deny the above.

This is the designed limit in Atlas, as the limits page points out:

If any of these limits present a problem for your organization, contact Atlas support.

There are limitations of the cloud vendor environments that need to be navigated. MongoDB Support will make you aware of those and what options are available.

1 Like

There is no limit on the number of shards for MongoDB. 50 shards is just the limit we put in the Atlas User Interface because we believe that the majority of users will not need to start with more than 50 shards.

We feel that it’s prudent for MongoDB to speak to those who want to start out with more than 50 in order to help ensure that they have the correct setup in place.

Oh, so the limit of 50 for Atlas only applies during the initial setup? Does that mean that after the initial setup, the user is then free to scale to 50+ shards?

not the initial setup, Atlas just wants to be aware if someone wants to go past 50 shards. You’re free to scale past 50 shards, but you just need to contact Atlas and say “I want to add N more shards”. We’re contemplating raising that “contact us” limit since quite a few people have wondered if we have a 50-shard limit on Atlas.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.