Increase MongoDB Cluster Shards

DBaaS allows you to increase the number of shards for MongoDB Enterprise sharded clusters. An increased shard count increases the overall storage of the cluster.

Note: We recommend you to review the Considerations before adding shards.

To increase the number of shards, send a PATCH request with the new shards count.

Endpoint

Use the following endpoint to request the new instances count: https://api.ionos.com/databases/mongodb/clusters/{clusterId}

Note:

  • The sample UUID is d02de413-d5af-4104-a6f9-3a3c2766ee61.

  • You can increase the number of shards to a maximum of 100.

Request

curl --include \
    --request PATCH \
    --user "[email protected]:Mb2.r5oHf-0t" \
    --header "Content-Type: application/json" \
    --data-binary '{
      "properties": {
        "shards": 3
      }
    }' 
    https://api.ionos.com/databases/mongodb/clusters/d02de413-d5af-4104-a6f9-3a3c2766ee61

Response

{
  "type": "cluster",
  "id": "d02de413-d5af-4104-a6f9-3a3c2766ee61",
  "metadata": {
    "state": "BUSY",
    "health": "HEALTHY",
    "createdDate": "2020-12-10T12:37:50.000Z",
    "createdBy": "[email protected]",
    "createdByUserId": "012342f-411f-1eeb-9d07-046c59cc737e"
  },
  "properties": {
    "displayName": "Represents database name",
    "location": "de/fkb",
    "connections": [
      {
        "datacenterId": "b72ebcf5-6158-4ddb-8f65-31b20d82b6c7",
        "lanId": "2",
        "cidrList": [
          "10.1.1.3/24",
          "10.1.1.4/24",
          "10.1.1.5/24"
        ]
      }
    ],
    "mongoDBVersion": "6.0",
    "instances": 3,
    "maintenanceWindow": {
      "dayOfTheWeek": "Thursday",
      "time": "08:53:15"
    },
    "connectionString": "mongodb+srv://m-65f4a879f126e3c4.mongodb.de-fra.ionos.com",
    "backup": {},
    "edition": "enterprise",
    "cores": 1,
    "ram": 2048,
    "storageSize": 10240,
    "storageType": "SSD Standard",
    "shards": 3,
    "biConnector": {
      "enabled": false
    },
    "type": "sharded-cluster"
  }
}

The PATCH example modifies a previously created sharded cluster and sets the number of shards to three.

New shards added this way are created by provisioning new servers and adding them to the sharded cluster. Each shard has the number of servers provided by the instances field. Sharded collections' data will then be distributed to the new shards. For more information, see Balancer Internals.

Note: Decreasing shards is currently not possible.

Last updated

Was this helpful?