For AI agents: a documentation index is available at https://www.mongodb.com/es/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

Config Shard

Starting in MongoDB 8.0, you can configure a config server to store your application data in addition to the usual sharded cluster metadata. A mongod node that provides both config server and shard server functionality is called a config shard. A mongod node that runs as a standalone --configsvr without shard server functionality is called a dedicated config server.

A sharded cluster must have a config server, but it can be either a config shard (embedded config server) or a dedicated config server. Using a config shard reduces the number of nodes required and can simplify your deployment. A config shard cluster is also called an embedded config server cluster. You cannot use the same config server for multiple sharded clusters.

A config shard costs less than a dedicated config server because a dedicated config server runs as its own replica set. A config shard combines the config server role into an existing shard's replica set, so your cluster needs one replica set instead of two. Using a config shard has no measurable performance impact at low shard counts. A dedicated config server isolates cluster metadata from application data, which certain features require.

Use a dedicated config server if you use one or more of the following features:

On MongoDB Atlas, a cluster automatically transitions from a config shard to a dedicated config server when the cluster has more than five shards.

In an embedded config server cluster, a config shard will be used to store cluster metadata and user data. It helps reduce the complexity of a sharded cluster deployment.

You can store sharded and unsharded collection data in your config shard. It has all the properties of a shard as well as acting as the config server.

You can confirm that a sharded cluster uses a config shard by using one of the following methods:

  • Run the sh.isConfigShardEnabled() method in mongosh. If the sh.isConfigShardEnabled() output contains enabled: true, the cluster uses a config shard. If the output contains enabled: false, the cluster does not use a config shard.

  • Run the listShards command against the admin database while connected to a mongos and inspect the output for a document where _id is set to "config". If the listShards output does not contain a document where _id is set to "config", the cluster does not use a config shard.

The following example runs the listShards command and tries to find a document where _id is set to "config".

db.adminCommand({ listShards: 1 })["shards"].find(element => element._id === "config")

In this example, the returned document has _id set to "config" which confirms that this cluster uses a config shard.

{
_id: "config",
host: "configRepl/localhost:27018",
state: 1,
topologyTime: Timestamp({ t: 1732218671, i: 13 }),
replSetConfigVersion: Long('-1')
}

To configure a dedicated config server to run as a config shard, run the transitionFromDedicatedConfigServer command.

To configure a config shard to run as a dedicated config server, run the transitionToDedicatedConfigServer command.