Sharding Definition :
Sharding in MongoDB is the process of storing data records across multiple machines. It is an approach to meet the demands of data growth. As the data size increases, a single machine might not be sufficient for storing the data nor provides an acceptable read and write throughput. Sharding can solve the problem with horizontal scaling. With sharding, you can add more machines for supporting data growth and the demands of read and write operations.
Sharding Cluster Configuration
Config Servers − Config servers will store the cluster's
metadata and this data contains a mapping of the cluster's data set to the
shards. Query router will use this metadata to target operations for specific
shards. In any production environment, sharded clusters will have exactly 3
config servers.
Query Routers − Query routers are mainly mongo instances
that interface with client applications and will direct operations to the
appropriate shard. Query router will process and target the operations to
shards and will then return results to the clients. A sharded cluster consists
of more than one query router for dividing the client request load and a client
will send requests to one query router. Basically, a sharded cluster can have
many query routers.
Shards Shards are used for storing data and they
provide high availability and data consistency. In the production environment, each
shard will be a separate replica set.