Help Center> ServiceStage> User Guide> Component Management> Configuring a Scaling Policy of a Component Instance
Updated on 2024-05-28 GMT+08:00

Configuring a Scaling Policy of a Component Instance

After scaling policies are configured, instances can be automatically added or deleted based on resource changes or a specified schedule. This reduces manual resource adjustment to cope with service changes and service peak, helping you save resources and labor costs.

  • Graceful scaling-in

    You can configure graceful scale-in policies only for the components deployed in the Kubernetes environment.

    You can set a graceful scale-in time window to save important data before a component instance stops. The value ranges from 0 to 9999, in seconds. The default value is 30. For example, if an application has two instances and only one instance will be kept after the scale-in operation, you can still perform certain operations on the instance to be stopped in the specified time window.

  • Manual scaling

    The number of instances will be increased or decreased immediately after the configuration is complete.

  • HPA

    Only CCE cluster 1.13 and later support HPA.

    HPA is a built-in component of Kubernetes, which enables horizontal scaling of pods. It supports the application-level cooldown time window and scaling threshold functions based on the Kubernetes HPA.

Configuring a Graceful Scale-In Policy

  1. Log in to ServiceStage.
  2. Use either of the following methods to go to the Scaling page.

    • On the Application Management page, click the application to which the component belongs, and click the target component in Component List. Alternatively, right-click the component and go to the component Overview page from the shortcut menu, and choose Scaling in the left navigation pane.
    • On the Component Management page, click the target component. Alternatively, right-click the component and go to the component Overview page from the shortcut menu, and choose Scaling in the left navigation pane.

  3. On the Scaling page, configure a graceful scale-in policy.

    Set Graceful Time Window (s). Specifically, click , enter a value, and click .

    Figure 1 Configuring a graceful scale-in policy

Configuring a Manual Scaling Policy

  1. Log in to ServiceStage.
  2. Use either of the following methods to go to the Scaling page.

    • On the Application Management page, click the application to which the component belongs, and click the target component in Component List. Alternatively, right-click the component and go to the component Overview page from the shortcut menu, and choose Scaling in the left navigation pane.
    • On the Component Management page, click the target component. Alternatively, right-click the component and go to the component Overview page from the shortcut menu, and choose Scaling in the left navigation pane.

  3. In the Manual Scaling area on the Scaling page, configure a manual scaling policy.

    • To deploy a component in the Kubernetes environment, perform the following operations:
      1. Click and change the number of instances.
      2. Click for the instance scaling to take effect.
      Figure 2 Configuring a manual scaling policy (for Kubernetes components)
    • For components deployed on a VM, perform the following operations:
      1. In the Instances area, click .
      2. Select Type and add or delete component running instances based on the site requirements.

        If Type is set to Scale Out, click Add ECS and create an ECS to run new component instances. For details, see Purchasing ECSs.

        If Type is set to Scale In, the number of running component instances can be reduced to 1.

      3. Click OK.
      Figure 3 Configuring a manual scaling policy (for VM components)

Configuring an HPA Policy

  1. Log in to ServiceStage.
  2. Use either of the following methods to go to the Scaling page.

    • On the Application Management page, click the application to which the component belongs, and click the target component in Component List. Alternatively, right-click the component and go to the component Overview page from the shortcut menu, and choose Scaling in the left navigation pane.
    • On the Component Management page, click the target component. Alternatively, right-click the component and go to the component Overview page from the shortcut menu, and choose Scaling in the left navigation pane.

  3. On the Scaling page, click next to Auto Scaling by HPA to enable auto scaling policy configuration. The Policy page is displayed.

    • If metrics-server has not been installed in the CCE cluster, go to 4.
    • If metrics-server has been installed in the CCE cluster, go to 6.

  4. Click Configure Now to install the metrics-server add-on on the CCE console.

    Install the metrics-server add-on for the CCE cluster. For details, see metrics-server.

  5. After the add-on is installed, return to the Policy page and click refresh.
  6. Configure the scaling policy.

    1. Policy Name

      Enter a policy name. After an auto scaling policy is configured, its name cannot be changed.

    2. Cooldown Period

      Enter a scale-out/scale-in cooldown period.

      The same scaling operation will not be triggered again within the specified period.

    3. Pod Range

      Enter the minimum and maximum numbers of instances.

      After the policy is triggered, the workload pods are scaled within this range.

    4. Trigger Condition

      You can configure trigger condition on the GUI or by editing the YAML file.

      • GUI

        Set Desired Value and Threshold (scale-in and scale-out thresholds) of CPU usage and Memory usage.

        After the policy is triggered, the number of instances to be scaled is calculated by rounding up the value of (Current CPU or memory usage/Expected value x Number of running instances).

        • Scale-in is triggered when the current CPU or memory usage is less than the scale-in threshold.
        • Scale-out is triggered when the current CPU or memory usage is greater than the scale-out threshold.
      • YAML
         metrics:
           - type: Resource
             resource:
               name: cpu
               target:
                 type: Utilization
                 averageUtilization: 50
           - type: Resource
             resource:
               name: memory
               target:
                 type: Utilization
                 averageUtilization: 50
           - type: Pods
             pods:
               metric:
                 name: packets-per-second
               target:
                 type: AverageValue
                 averageValue: 1k
           - type: Object
             object:
               metric:
                 name: requests-per-second
               describedObject:
                 apiVersion: networking.k8s.io/v1beta1
                 kind: Ingress
                 name: main-route
               target:
                 type: Value
                 value: 10k

        As shown in the preceding example, in addition to using the CPU and memory usage as metrics, you can use the YAML format to customize metric parameters and support more metrics such as pods, object, and external.

        To configure custom metric parameters by using YAML, ensure that the prometheus add-on has been installed for the CCE cluster.

        Install the prometheus add-on for the CCE cluster. For details, see prometheus.

  7. Click OK.

    After the HPA policy is configured, you can perform the following operations based on service requirements:

Modifying an HPA Policy

You can edit an existing HPA policy and reconfigure policy parameters.

  1. Log in to ServiceStage.
  2. Use either of the following methods to go to the Scaling page.

    • On the Application Management page, click the application to which the component belongs, and click the target component in Component List. Alternatively, right-click the component and go to the component Overview page from the shortcut menu, and choose Scaling in the left navigation pane.
    • On the Component Management page, click the target component. Alternatively, right-click the component and go to the component Overview page from the shortcut menu, and choose Scaling in the left navigation pane.

  3. On the Scaling page, choose Policy, click Edit Policy, and reconfigure parameters.

    1. Cooldown Period

      Change the scale-out/scale-in cooldown period.

    2. Pod Range

      Change the minimum and maximum numbers of instances.

    3. Trigger Condition

      You can change trigger condition on the GUI or by editing the YAML file.

      • GUI

        Change Desired Value and Threshold (scale-in and scale-out thresholds) of CPU usage and Memory usage.

      • YAML

        You can use the YAML format to customize metric parameters and support more metrics such as pods, objects, and external.

        To configure custom metric parameters by using YAML, ensure that the prometheus add-on has been installed for the CCE cluster.

        Install the prometheus add-on for the CCE cluster. For details, see prometheus.

  4. Click OK.

Viewing the Running Status of the HPA Policy

ServiceStage allows you to view the running status and events of a configured HPA policy.

  1. Log in to ServiceStage.
  2. Use either of the following methods to go to the Scaling page.

    • On the Application Management page, click the application to which the component belongs, and click the target component in Component List. Alternatively, right-click the component and go to the component Overview page from the shortcut menu, and choose Scaling in the left navigation pane.
    • On the Component Management page, click the target component. Alternatively, right-click the component and go to the component Overview page from the shortcut menu, and choose Scaling in the left navigation pane.

  3. On the Scaling page:

    • Click the Status tab to view the policy running status.
    • Click the Event tab to view events that occur during policy running.

Deleting an HPA Policy

You can delete an HPA policy that is no longer used.

Deleted policies cannot be recovered. Exercise caution when performing this operation.

  1. Log in to ServiceStage.
  2. Use either of the following methods to go to the Scaling page.

    • On the Application Management page, click the application to which the component belongs, and click the target component in Component List. Alternatively, right-click the component and go to the component Overview page from the shortcut menu, and choose Scaling in the left navigation pane.
    • On the Component Management page, click the target component. Alternatively, right-click the component and go to the component Overview page from the shortcut menu, and choose Scaling in the left navigation pane.

  3. On the Scaling page, click on the right of Auto Scaling by HPA.
  1. Click OK.