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). A mongos 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 is shown in the following diagram:

As of MongoDB 3.6, shards must be implemented as replica sets.

Get Mastering MongoDB 4.x - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.