Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongodb - sharded and unsharded collections

I'm a bit confused as to how this works.

When sharding MySQL, we had some tables, usually small ones with reference data, whole in each shard. This was to enable joins.

If we have small collections in MongoDB, that we don't shard in a sharded setup, what happens to them? Do they get sent to each shard, or just stay in the first shard?

This strikes me as a possible potential bottleneck, if all processes in a heavily sharded system with many application servers were hitting on one server.

like image 474
CargoMeister Avatar asked Aug 28 '13 05:08

CargoMeister


1 Answers

In MongoDB with the autosharding feature, a sharded collection will be distributed somehow evenly along all the shards you have.

With those collections which you not likely to shard (which are not sharded) you can specify a primary shard which will they reside on. This primary shard is a given one for a specific database, so it is on per database level. Can be moved and can be different for different databases.

There is the notion of shard tagging which with you can influence for sharded collections where to be placed. Basicly you can constraint a collection or a part of a collection to be stored on a specific set of shards. (Reference)

like image 165
attish Avatar answered Sep 28 '22 02:09

attish