- Sharding >
- Sharded Cluster Components
Sharded Cluster Components¶
On this page
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. - config servers: Config servers store metadata and configuration settings for the cluster. As of MongoDB 3.2, config servers can be deployed as a replica set.
Production Configuration¶
In a production cluster, ensure that data is redundant and that your systems are highly available. Consider the following for a production sharded cluster deployment:
- Deploy Config Servers as a 3 member replica set
- Deploy each Shard as a 3 member replica set
- Deploy one or more
mongos
routers
Where possible, consider deploying one member of each replica set in a site suitable for being a disaster recovery location.
Sharding requires at least two shards to distribute sharded data. Single shard sharded clusters may be useful if you plan on enabling sharding in the near future, but do not need to at the time of deployment.
You can deploy a mongos
router on each application server to ensure
each server has consistent access to the sharded cluster. Alternatively,
deploy a group of mongos
routers and use a proxy or load balancer
between the application and the mongos
group. In these deployments,
you must configure the load balancer for client affinity such that every
connection from a single client reaches the same mongos
.
Development Configuration¶
For testing and development, you can deploy a sharded cluster with a minimum number of components. These non-production clusters have the following components:
- A replica set config server with one member.
- At least one shard as a single-member replica set.
- One
mongos
instance.
Warning
Use the test cluster architecture for testing and development only.
See also