← All tutorials

GoCareerGo Tutorials

MongoDB Tutorial

Documents, collections, CRUD, aggregation, Atlas and driver connectivity.

Sharding in MongoDB

Sharding horizontally partitions a large collection across multiple servers (shards), based on a shard key — enabling scale beyond a single machine.

  • Shard key — the field used to decide which shard a document lives on
  • A good shard key has high cardinality and even value distribution
  • mongos — the query router that directs each operation to the right shard(s)