starrocks-kubernetes-operator

Automatic scaling for CN nodes

This topic describes how to configure automatic scaling for CN nodes in a StarRocks cluster.

Prerequisites

Suppose you have installed a StarRocks cluster named starrockscluster-sample under the starrocks namespace

There are two ways to deploy StarRocks cluster:

  1. Deploy StarRocks cluster with StarRocksCluster CR yaml.
  2. Deploy StarRocks cluster with Helm chart.

Therefore, there are two ways to configure automatic scaling for CN nodes.

You can specify the resource metrics for CNs, such as average CPU utilization, average memory usage, elastic scaling threshold, upper elastic scaling limit, and lower elastic scaling limit. The upper elastic scaling limit and lower elastic scaling limit specify the maximum number and minimum number of CNs allowed for elastic scaling.

Configure automatic scaling for CN nodes by using CR yaml

Run the command kubectl -n starrocks edit src starrockscluster-sample` to configure the automatic scaling policy for CN nodes.

NOTE

If you have configured the automatic scaling policy for the CN cluster, delete the replicas field from the starRocksCnSpec in the StarRocks cluster configuration file.

The following is a template to help you configure automatic scaling policies:

  starRocksCnSpec:
    image: starrocks/cn-ubuntu:3.0-latest
    requests:
      cpu: 4
      memory: 4Gi
    autoScalingPolicy: # Automatic scaling policy of the CN cluster.
      maxReplicas: 10 # The maximum number of CNs is set to 10.
      minReplicas: 1 # The minimum number of CNs is set to 1.
      hpaPolicy:
        metrics: # Resource metrics
          - type: Resource
            resource:
              name: memory # The average memory usage of CNs is specified as a resource metric.
              target:
                averageUtilization: 30
                # The elastic scaling threshold is 30%.
                # When the average memory utilization of CNs exceeds 30%, the number of CNs increases for scale-out.
                # When the average memory utilization of CNs is below 30%, the number of CNs decreases for scale-in.
                type: Utilization
          - type: Resource
            resource:
              name: cpu # The average CPU utilization of CNs is specified as a resource metric.
              target:
                averageUtilization: 60
                # The elastic scaling threshold is 60%.
                # When the average CPU utilization of CNs exceeds 60%, the number of CNs increases for scale-out.
                # When the average CPU utilization of CNs is below 60%, the number of CNs decreases for scale-in.
                type: Utilization
        behavior: #  The scaling behavior is customized according to business scenarios, helping you achieve rapid or slow scaling or disable scaling.
          scaleUp:
            policies:
              - type: Pods
                value: 1
                periodSeconds: 10
          scaleDown:
            selectPolicy: Disabled

Configure automatic scaling for CN nodes by using Helm chart

Add the following snippets to values.yaml to configure the automatic scaling policy for CN nodes,

  starrocksCluster: # do not forget to set enabledCn to true to enable deployment of CNs.
    enabledCn: true

  starrocksCnSpec:
    image:
      repository: starrocks/cn-ubuntu
      tag: 3.3-latest
    resources:
      requests:
        cpu: 4
        memory: 4Gi
    autoScalingPolicy:
      minReplicas: 1
      maxReplicas: 10
      hpaPolicy:
        metrics: # Resource metrics
          - type: Resource
            resource:
              name: memory # The average memory usage of CNs is specified as a resource metric.
              target:
                averageUtilization: 30
                # The elastic scaling threshold is 30%.
                # When the average memory utilization of CNs exceeds 30%, the number of CNs increases for scale-out.
                # When the average memory utilization of CNs is below 30%, the number of CNs decreases for scale-in.
                type: Utilization
          - type: Resource
            resource:
              name: cpu # The average CPU utilization of CNs is specified as a resource metric.
              target:
                averageUtilization: 60
                # The elastic scaling threshold is 60%.
                # When the average CPU utilization of CNs exceeds 60%, the number of CNs increases for scale-out.
                # When the average CPU utilization of CNs is below 60%, the number of CNs decreases for scale-in.
                type: Utilization
        behavior: #  The scaling behavior is customized according to business scenarios, helping you achieve rapid or slow scaling or disable scaling.
          scaleUp:
            policies:
              - type: Pods
                value: 1
                periodSeconds: 10
          scaleDown:
            selectPolicy: Disabled

Fields description

The following are descriptions of a few important fields: