Architectural overview
A sharded cluster is comprised of the following elements:
- Two or more shards. Each shard must be a replica set.
- One or more query routers (
mongos
). Amongos
router provides an interface between our application and the database. - A replica set of config servers. Config servers store metadata and configuration settings for the entire cluster.
The relationships between these elements are shown in the following diagram:
Figure 14.2: MongoDB sharded cluster architecture
Starting from MongoDB 3.6, shards must be implemented as replica sets.
Development, continuous deployment, and staging environments
In preproduction environments, it may be overkill to use the full set of servers. For efficiency reasons, we may opt to use a more simplified architecture.
The simplest possible configuration that we can deploy for sharding is the following:
- One
mongos
router - One sharded replica set with one MongoDB server...