On this page
- Is sharding appropriate for a new deployment?
- Can I select a different shard key after sharding a collection?
- Why are my documents not distributed across the shards?
- How does
mongosdetect changes in the sharded cluster configuration?
- What does
writebacklistenin the log mean?
- How does
- Shard Keys and Considerations for Shard Key Selection
- Query Routing
- High Availability
- Data Partitioning with Chunks and Chunk Migration Process
- Troubleshoot Sharded Clusters
Sometimes. However, if your data set fits on a single server, you should begin with an unsharded deployment as sharding while your data set is small provides little advantage .
Your options for changing a shard key depend on the version of MongoDB that you are running:
- Starting in MongoDB 5.0, you can reshard a collection by changing a document's shard key.
- Starting in MongoDB 4.4, you can refine a shard key by adding a suffix field or fields to the existing shard key.
- In MongoDB 4.2 and earlier, the choice of shard key cannot be changed after sharding.
In MongoDB 4.2 and earlier, if you must change a shard key after sharding a collection and cannot upgrade, the best option is to:
- dump all data from MongoDB into an external format.
- drop the original sharded collection.
- configure sharding using a more ideal shard key.
- pre-split the shard key range to ensure initial even distribution.
- restore the dumped data into MongoDB.
The balancer starts distributing data across the shards once the distribution of chunks has reached certain thresholds. See Migration Thresholds.
mongos updates its cache lazily by issuing a request to a
shard and discovering that its metadata is out of date. To force the
mongos to reload its cache, you can run the
flushRouterConfig command against each
The writeback listener is a process that opens a long poll to relay
writes back from a
migrations to make sure they have not gone to the wrong server. The
writeback listener sends writes back to the correct server if
These messages are a key part of the sharding infrastructure and should not cause concern.
mongos instance maintains a pool of connections to the
members of the sharded cluster. Client requests use these connections
one at a time; i.e. requests are not multiplexed or pipelined.
When client requests complete, the
mongos returns the
connection to the pool. These pools do not shrink when the number of
clients decreases. This can lead to an unused
mongos with a
large number of open connections. If the
mongos is no longer
in use, it is safe to restart the process to close existing connections.