MongodDB Sharding Part 1 : Intro
When there’s performance issue in the DB and scale vertical is no longer the option for you to resolve the issue. Then scale horizontally would be the solution for you on this matter.
MongoDB Sharding split large data sets into smaller data sets across different servers. Actually all the shards works as a collection, it’s just that those data are stored in different servers.
With this we can add more servers to support data growth and also cater the read and write demand.
Sharding consist of 3 components:
- Config Server
- Shards
- Query Router
Config server stores the metadata of the cluster. In another words, it holds the information of which shards are storing which data.
Shards stores the subset of the data. Each shards consists of multiple replica sets. Hence, shards provide high availability. If the primary replica sets is down, the secondary replica set will be promoted as the master.
Query router is responsible for redirecting the command from the client to the respective server. The client will be connected to the query router not the shards or config server.