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.
Before we cover how to implement a sharded cluster, it's important to understand how sharding operates...