Docs Menu

Modify Chunk Size in a Sharded Cluster

The default chunk size for a sharded cluster is 128 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. The allowed range of the chunk size is between 1 and 1024 megabytes, inclusive.

To modify the chunk size, use the following procedure:

  1. Connect to any mongos in the cluster using mongosh.
  2. Issue the following command to switch to the Config Database:

    use config
  3. Issue the following command to store the global chunk size configuration value:

    db.settings.updateOne(
    { _id: "chunksize" },
    { $set: { _id: "chunksize", value: <sizeInMB> } },
    { upsert: true }
    )

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.
  • The allowed range of the chunk size is between 1 and 1024 megabytes, inclusive.
←  Merge Chunks in a Sharded ClusterSharded Cluster Balancer →
Give Feedback
© 2022 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.