- Sharding >
- Sharded Cluster Tutorials >
- Sharded Cluster Data Management >
- Modify Chunk Size in a Sharded Cluster
Modify Chunk Size in a Sharded Cluster¶
When the first mongos
connects to a set of config
servers, it initializes the sharded cluster with a
default chunk size of 64 megabytes. This default chunk size works well
for most deployments; however, if you notice that automatic migrations
have more I/O than your hardware can handle, you may want to reduce the
chunk size. For automatic splits and migrations, a small chunk size
leads to more rapid and frequent migrations.
To modify the chunk size, use the following procedure:
Issue the following command to switch to the Config Database:
Issue the following
save()
operation to store the global chunk size configuration value:
Note
The chunkSize
and
--chunkSize
options, passed at startup to the mongos
,
do not affect the chunk size after you have initialized the
cluster.
To avoid confusion, always set the chunk size using the above procedure instead of the startup options.
Modifying the chunk size has several limitations:
- Automatic splitting only occurs on insert or update.
- If you lower the chunk size, it may take time for all chunks to split to the new size.
- Splits cannot be undone.
- If you increase the chunk size, existing chunks grow only through insertion or updates until they reach the new size.