Sharding

Command summary:

  • sh.addShard( "host:port" )
  • sh.enableSharding( "database" )
  • sh.shardCollection( "database.collection", { field: direction } )
  • sh.status()

Whereas replication is designed to provide redundancy of data, sharding is a feature which provides horizontal scaling. This means that instead of having a single extremely powerful server (vertical scaling), you spread the data across multiple servers operating in a cluster. This facility gives you the ability to handle massive amounts of data and lends itself to the cloud environment. Not only that, but because you have a subset of the entire database residing on multiple servers, each server is then able to handle its own database tasks, thus providing a means of load balancing ...

Get MongoDB 4 Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.