Config Shard
On this page
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.
Use Cases
You can consider using a config shard if your cluster has three or fewer shards.
If your application has demanding availability and resiliency requirements, consider deploying a dedicated config server. A dedicated config server provides isolation, dedicated resources, and consistent performance for critical cluster operations.
You should use a dedicated config server if you satisfy one or more of the following conditions:
You plan to use more than three shards.
You plan to use Time series collections or Queryable Encryption collections.
You plan to use queryable backups (on-prem).
Behavior
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.
Confirm use of Config Shard
To confirm that a sharded cluster uses 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') }
Commands
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.