Explain the process of Sharding

Sharding is a method for distributing data across multiple machines. MongoDB uses sharding to support deployments with very large data sets and high throughput operations.

MongoDB supports horizontal scaling through sharding by dividing the system dataset and load over multiple servers, adding additional servers to increase capacity as required.

Sharded Cluster

A MongoDB sharded cluster consists of the following components:

shard: Each shard contains a subset of the sharded data. Each shard can be deployed as a replica set.

mongos: The mongos acts as a query router, providing an interface between client applications and the sharded cluster. Starting in MongoDB 4.4, mongos can support hedged reads to minimize latencies.

config servers: Config servers store metadata and configuration settings for the cluster.


Sharding — MongoDB Manual. mongodb.com/docs/manual/sharding.