edit-icon download-icon

Container auto scaling

Last Updated: Jan 09, 2018

To meet the demands of applications under different loads, Container Service supports auto scaling for the service, which automatically adjusts the number of containers according to the container resource usage in the service.

You can configure the container auto scaling rules when creating applications or add the container auto scaling rules for existing applications by changing application configurations.

Auto scaling policies:

  • When the monitoring metric value exceeds the configured upper limit, Container Service increases the number of containers at your configured step.
  • When the monitoring metric value is lower than the configured lower limit, Container Service reduces the number of containers at your configured step.

Service monitoring metrics:

  • Average CPU usage
  • Average memory usage
  • Container inbound rate (currently only support being configured by using orchestration templates)
  • Container outbound rate (currently only support being configured by using orchestration templates)

Prerequisites

  • Upgrade the cluster Agent to the latest version. For more information, see Upgrade Agent.

  • Upgrade the cluster monitoring service (acsmonitoring) to the latest version. For more information, see Upgrade system services.

  • Activate the RAM service and update the RAM authorization information in the cluster by completing the following steps:

    1. Log on to the Container Service console.
    2. Click Clusters in the left-side navigation pane.
    3. Click More at the right of the cluster.
    4. Select Update RAM Authorization Information from the list.

Instructions

  • When determining whether the monitoring metric value exceeds the configured upper limit or lower limit, Container Service uses the average value of the monitoring metrics (namely, the average CPU usage and the average memory usage) within a sample period (one minute). Container Service triggers scaling only when the average monitoring metrics of three consecutive sample periods all exceed the configured upper limit or lower limit so as to avoid frequent scaling caused by monitoring data jitter.

  • During container contraction, the system deletes the containers in the cluster. Therefore, back up the data in advance.

Set container auto scaling

You can set the container auto scaling in the following ways:

Note: If your configured container auto scaling rule does not take effect, see What if the auto scaling rule does not take effect for troubleshooting.

Create an application by using an image

  1. Click Create with Image when creating an application.

    For how to create an application, see Create an application.

    1

  2. In the Deploy section at the bottom of the page, select the Enable check box for Auto Scaling and set the auto scaling parameters.

    Constraint rules:

    • The range of the Expansion Condition is 50%–100%. The range of the Contraction Condition is 0%–50%.
    • The Expansion Condition must be at least 30% higher than the Contraction Condition.
    • The range of the Step is 1–5. The default value is 1.
    • Set the Min Number of Containers and Max Number of Containers. For contraction, if the number of containers is less than or equal to the Min Number of Containers, contraction is not performed. For expansion, if the number of containers is greater than or equal to the Max Number of Containers, expansion is not performed.

    Note:

    • We recommend that you do not configure the compound scaling rules based on the CPU usage and memory usage at the same time.
    • Set the scaling policies with due care. If the application already meets the configured scaling conditions when you set the scaling rules and the application still meets the scaling conditions after the scaling, the monitoring will continuously trigger the scaling.

    1

Create an application by using an orchestration template

  1. Click Create with Orchestration Template when creating an application.

    For how to create an application, see Create an application.

    1

  2. Click Use Existing Orchestration Template or write your own orchestration template.

  3. Add the configurations of the container auto scaling by:

    • Clicking Add Service.

      1

      In the displayed dialog box, select the image (nginx in this example) and configure the corresponding parameters. Click More Settings. Select the Enable check box for Auto Scaling and set the auto scaling parameters.

    • Manually configuring in the template.

      In the labels configurations of the orchestration template, add the corresponding labels:

      • Specify the step (the default value is 1): aliyun.auto_scaling.step
      • Specify the minimum number of containers (the default value is 1): aliyun.auto_scaling.min_instances
      • Specify the maximum number of containers (the default value is 10): aliyun.auto_scaling.max_instances
      • CPU usage as the metric
        • Specify the upper limit: aliyun.auto_scaling.max_cpu
        • Specify the lower limit: aliyun.auto_scaling.min_cpu
      • Memory usage as the metric
        • Specify the upper limit: aliyun.auto_scaling.max_memory
        • Specify the lower limit: aliyun.auto_scaling.min_memory
      • Outbound rate (bytes/s) as the metric
        • Specify the upper limit: aliyun.auto_scaling.max_internetOutRate
        • Specify the lower limit: aliyun.auto.scaling.min_internetOutRate
      • Inbound rate (bytes/s) as the metric
        • Specify the upper limit: aliyun.auto_scaling.max_internetInRate
        • Specify the lower limit: aliyun.auto_scaling.min_internetInRate

      Example:

      1

Change application configurations

You can add auto scaling settings for containers by changing the configurations of an existing application.

  1. On the Application List page, click Update at the right of the application you want to add the container auto scaling settings.

    For how to change the application configurations, see Change application configurations.

    1

  2. In the labels configurations in Template, add the corresponding container auto scaling labels.

    1

View created container scaling rules

You can view the created container scaling rules.

  1. Log on to the Container Service console.

  2. Click Applications in the left-side navigation pane.

  3. On the Application List page, click Update at the right of the application.

    You can view the created container scaling rules. You can modify the container scaling rules in the Template.

    1

Thank you! We've received your feedback.