Updated on 2026-09-20 GMT+08:00

Scaling Out a Cluster

Function

This API is used to scale out a cluster or add idle nodes. By default, scale-out is performed.

You can configure create_node_only to determine whether the current operation is to scale out a cluster or add idle nodes.

  • true: Add idle nodes.

  • false: Scale out a cluster.

Calling Method

For details, see Calling APIs.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    dws:cluster:scaleOut

    Write

    cluster *

    • g:ResourceTag/<tag-key>

    • g:EnterpriseProjectId

    • dws:VpcId

    • dws:SubnetId

    -

    -

URI

POST /v1.0/{project_id}/clusters/{cluster_id}/resize

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

cluster_id

Yes

String

Definition

Cluster ID. For details about how to obtain the value, see Obtaining the Cluster ID.

Constraints

N/A

Range

N/A

Default Value

N/A

project_id

Yes

String

Definition

Project ID. To obtain the value, see Obtaining a Project ID.

Constraints

N/A

Range

N/A

Default Value

N/A

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

scale_out

Yes

ScaleOut object

Definition

Request body for adding an idle node or scaling out a cluster.

Constraints

N/A

Range

N/A

Default Value

N/A

logical_cluster_name

No

String

Definition:

Name of the logical cluster, which is required when the cluster is scaled out to a logical cluster.

Constraints:

None

Range:

None

Default Value:

None

create_node_only

No

Boolean

Definition

Whether only idle nodes are added.

Constraints

N/A

Range

true: Only nodes are added. If scale-out is required, perform it separately.

false: Nodes are added and the cluster is scaled out.

Default Value

false

waiting_for_killing

No

Integer

Definition

Time before blocked job termination.

Constraints

This parameter is available only for GuestAgent 8.2.1 or later.

Range

30 to 1200

Default Value

0 (not limited)

auto_redistribute

No

Boolean

Definition:

Whether to automatically start redistribution after scale-out. The default value is Yes. If this parameter is set to false, redistribution is not performed after scale-out. In this case, the cluster task information is in the to-be-redistributed state and other operations cannot be performed.

Constraints:

None

Range:

  • true: Redistribute data immediately after scale-out.

  • false: Data is not redistributed after scale-out. In this case, the cluster task information is in the to-be-redistributed state.

Default Value:

true

mode

No

String

Definition

Scale-out mode, which can be online or offline. During online scale-out, data can be added, deleted, modified, and queried, and some DDL syntaxes are supported. Errors will be reported for unsupported syntaxes. Online scale-out has less impact on services. In offline mode, services are interrupted for a short period of time and the database is unavailable.

Constraints

N/A

Range

  • insert: online mode

  • read-only: offline mode

Default Value

read-only

redis_conf

No

RedisConfReq object

Definition

Redistribution configuration. The offline mode is used by default.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 ScaleOut

Parameter

Mandatory

Type

Description

count

Yes

Integer

Definition

Number of nodes to be added.

Range

Greater than or equal to 3

subnet_id

No

String

Definition

Subnet ID.

Range

The value is a valid subnet ID in the same VPC.

Table 4 RedisConfReq

Parameter

Mandatory

Type

Description

redis_mode

Yes

String

Definition

Redistribution mode. The impact on services varies depending on the mode. You are advised to contact O&M personnel for evaluation before changing the mode.

Constraints

The value must be a valid DWS cluster ID.

Range

offline

online

Default Value

offline

parallel_jobs

Yes

Integer

Definition

Number of concurrent jobs. The default value is 4.

Constraints

N/A

Range

1 to 200

Default Value

4

Response Parameters

Status code: 200

Request for scaling out a cluster is submitted.

None

Example Requests

  • Add three nodes to a cluster.

    POST https://{Endpoint}/v1.0/89cd04f168b84af6be287f71730fdb4b/clusters/4ca46bf1-5c61-48ff-b4f3-0ad4e5e3ba90/resize
    
    {
      "scale_out" : {
        "count" : 3,
        "subnet_id" : null
      },
      "logical_cluster_name" : null,
      "create_node_only" : false,
      "waiting_for_killing" : 30,
      "auto_redistribute" : false,
      "mode" : "read-only",
      "redis_conf" : {
        "redis_mode" : "online",
        "parallel_jobs" : 5
      }
    }
  • Add three idle nodes to a cluster for the scale-out operation in example 3.

    POST https://{Endpoint}/v1.0/89cd04f168b84af6be287f71730fdb4b/clusters/4ca46bf1-5c61-48ff-b4f3-0ad4e5e3ba90/resize
    
    {
      "scale_out" : {
        "count" : 3
      },
      "create_node_only" : true
    }

Example Responses

Status code: 200

Request for scaling out a cluster is submitted.

{ }

SDK Sample Code

The SDK sample code is as follows.

  • Add three nodes to a cluster.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.dws.v2.region.DwsRegion;
    import com.huaweicloud.sdk.dws.v2.*;
    import com.huaweicloud.sdk.dws.v2.model.*;
    
    
    public class ResizeClusterSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
            String projectId = "{project_id}";
    
            ICredential auth = new BasicCredentials()
                    .withProjectId(projectId)
                    .withAk(ak)
                    .withSk(sk);
    
            DwsClient client = DwsClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(DwsRegion.valueOf("<YOUR REGION>"))
                    .build();
            ResizeClusterRequest request = new ResizeClusterRequest();
            request.withClusterId("{cluster_id}");
            ResizeClusterRequestBody body = new ResizeClusterRequestBody();
            RedisConfReq redisConfbody = new RedisConfReq();
            redisConfbody.withRedisMode("online")
                .withParallelJobs(5);
            ScaleOut scaleOutbody = new ScaleOut();
            scaleOutbody.withCount(3);
            body.withRedisConf(redisConfbody);
            body.withMode("read-only");
            body.withAutoRedistribute(false);
            body.withWaitingForKilling(30);
            body.withCreateNodeOnly(false);
            body.withScaleOut(scaleOutbody);
            request.withBody(body);
            try {
                ResizeClusterResponse response = client.resizeCluster(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    
  • Add three idle nodes to a cluster for the scale-out operation in example 3.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.dws.v2.region.DwsRegion;
    import com.huaweicloud.sdk.dws.v2.*;
    import com.huaweicloud.sdk.dws.v2.model.*;
    
    
    public class ResizeClusterSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
            String projectId = "{project_id}";
    
            ICredential auth = new BasicCredentials()
                    .withProjectId(projectId)
                    .withAk(ak)
                    .withSk(sk);
    
            DwsClient client = DwsClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(DwsRegion.valueOf("<YOUR REGION>"))
                    .build();
            ResizeClusterRequest request = new ResizeClusterRequest();
            request.withClusterId("{cluster_id}");
            ResizeClusterRequestBody body = new ResizeClusterRequestBody();
            ScaleOut scaleOutbody = new ScaleOut();
            scaleOutbody.withCount(3);
            body.withCreateNodeOnly(true);
            body.withScaleOut(scaleOutbody);
            request.withBody(body);
            try {
                ResizeClusterResponse response = client.resizeCluster(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    
  • Add three nodes to a cluster.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkdws.v2.region.dws_region import DwsRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkdws.v2 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
        projectId = "{project_id}"
    
        credentials = BasicCredentials(ak, sk, projectId)
    
        client = DwsClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(DwsRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = ResizeClusterRequest()
            request.cluster_id = "{cluster_id}"
            redisConfbody = RedisConfReq(
                redis_mode="online",
                parallel_jobs=5
            )
            scaleOutbody = ScaleOut(
                count=3
            )
            request.body = ResizeClusterRequestBody(
                redis_conf=redisConfbody,
                mode="read-only",
                auto_redistribute=False,
                waiting_for_killing=30,
                create_node_only=False,
                scale_out=scaleOutbody
            )
            response = client.resize_cluster(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Add three idle nodes to a cluster for the scale-out operation in example 3.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkdws.v2.region.dws_region import DwsRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkdws.v2 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
        projectId = "{project_id}"
    
        credentials = BasicCredentials(ak, sk, projectId)
    
        client = DwsClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(DwsRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = ResizeClusterRequest()
            request.cluster_id = "{cluster_id}"
            scaleOutbody = ScaleOut(
                count=3
            )
            request.body = ResizeClusterRequestBody(
                create_node_only=True,
                scale_out=scaleOutbody
            )
            response = client.resize_cluster(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Add three nodes to a cluster.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        dws "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
        projectId := "{project_id}"
    
        auth, err := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            SafeBuild()
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        hcClient, err := dws.DwsClientBuilder().
             WithRegion(region.ValueOf("<YOUR REGION>")).
             WithCredential(auth).
             SafeBuild()
    
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        client := dws.NewDwsClient(hcClient)
    
        request := &model.ResizeClusterRequest{}
    	request.ClusterId = "{cluster_id}"
    	redisConfbody := &model.RedisConfReq{
    		RedisMode: "online",
    		ParallelJobs: int32(5),
    	}
    	scaleOutbody := &model.ScaleOut{
    		Count: int32(3),
    	}
    	modeResizeClusterRequestBody:= "read-only"
    	autoRedistributeResizeClusterRequestBody:= false
    	waitingForKillingResizeClusterRequestBody:= int32(30)
    	createNodeOnlyResizeClusterRequestBody:= false
    	request.Body = &model.ResizeClusterRequestBody{
    		RedisConf: redisConfbody,
    		Mode: &modeResizeClusterRequestBody,
    		AutoRedistribute: &autoRedistributeResizeClusterRequestBody,
    		WaitingForKilling: &waitingForKillingResizeClusterRequestBody,
    		CreateNodeOnly: &createNodeOnlyResizeClusterRequestBody,
    		ScaleOut: scaleOutbody,
    	}
    	response, err := client.ResizeCluster(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Add three idle nodes to a cluster for the scale-out operation in example 3.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        dws "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
        projectId := "{project_id}"
    
        auth, err := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            SafeBuild()
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        hcClient, err := dws.DwsClientBuilder().
             WithRegion(region.ValueOf("<YOUR REGION>")).
             WithCredential(auth).
             SafeBuild()
    
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        client := dws.NewDwsClient(hcClient)
    
        request := &model.ResizeClusterRequest{}
    	request.ClusterId = "{cluster_id}"
    	scaleOutbody := &model.ScaleOut{
    		Count: int32(3),
    	}
    	createNodeOnlyResizeClusterRequestBody:= true
    	request.Body = &model.ResizeClusterRequestBody{
    		CreateNodeOnly: &createNodeOnlyResizeClusterRequestBody,
    		ScaleOut: scaleOutbody,
    	}
    	response, err := client.ResizeCluster(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

Request for scaling out a cluster is submitted.

400

Request error.

401

Authentication failed.

403

You do not have required permissions.

404

No resources found.

500

Internal server error.

503

Service unavailable.