Auto scaling is an important O&M capability for distributed application management. If auto scaling is enabled, the system can detect the status of each application instance and dynamically scale in or scale out the application based on the instance status. This ensures the service quality and improves the application availability. This topic describes how to configure auto scaling policies for applications. The procedure described in this topic applies to applications deployed in Container Service for Kubernetes (ACK) clusters and serverless Kubernetes clusters in Enterprise Distributed Application Service (EDAS).

Scenarios

Applications such as the Internet and game applications are prone to sudden traffic surges during promotional activities. The difficulty in the balance between service level agreements (SLAs) and resource costs may cause system issues, such as slow responses and breakdowns. EDAS inherits the traffic surge management technology that is used by Alibaba to cope with Double 11, and provides the second-level auto scaling feature. This ensures SLA compliance and reduces the costs of server retention. Auto scaling is applicable to industries such as the Internet, games, and social networking platforms.

Background information

You can configure auto scaling policies for applications that are deployed in ACK clusters and serverless Kubernetes clusters in EDAS.

You can configure multiple triggers for an auto scaling policy.
  • If the Kubernetes cluster version is earlier than V1.15.0, auto scaling can be triggered only when all the triggers are met.
  • If the Kubernetes cluster version is V1.15.0 or later, auto scaling can be triggered when one of the triggers is met. If multiple triggers are met, the system checks the number of expected instances configured for each trigger and selects the maximum as the number of expected instances for the application.
Notice
  • After an auto scaling policy is enabled, you cannot stop, start, or manually scale out or scale in your application. If you want to perform these operations, disable the auto scaling policy.
    • You may configure a Service for an application and bind a Server Load Balancer (SLB) instance to the application. In this case, if auto scaling occurs, EDAS automatically adds or removes application instances to or from the list of backend servers of the SLB instance.
    • You may configure persistent storage for an application. In this case, when auto scaling occurs, EDAS automatically associates application instances that are added with the configured persistent storage.
  • You cannot add an auto scaling policy if an application change, such as application deployment, application scaling, or specification change, is in progress.
  • If auto scaling of nodes is disabled for a Kubernetes cluster, the auto scaling feature for applications may be ineffective. You can go to the ACK console and configure auto scaling of nodes on the Clusters page.

Procedure

You can configure multiple triggers. EDAS automatically scales out or scales in application instances based on the triggers.

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. In the upper part of the page, select a namespace. On the Applications page, click the name of the desired application.
  3. In the left-side navigation pane of the application details page, choose Application Settings > Auto Scaling. On the page that appears, click Add Flexible Strategy.
    Alternatively, in the upper-right corner of the Application Overview page, choose Scale > Auto Scaling. On the page that appears, click Add Flexible Strategy.
  4. In the Strategy Name field, enter a name for the auto scaling policy.
  5. In the Triggering Conditions section, click Add trigger. In the Add trigger panel, configure a trigger rule. After the configuration is complete, click OK.
    Parameter Description
    Trigger name The name must start with a letter, and can contain digits, letters, hyphens (-), and underscores (_). The name can be up to 30 characters in length.
    Trigger type Select a trigger type provided by the system. You can select Timing trigger or Application indicator trigger.
    • Timing trigger
      1. cycle: Select every day or weekly from the drop-down list.
        Note If you select weekly, specify the day of a week as needed to configure the trigger rule. To configure different trigger rules for different days of a week, create multiple timing triggers.
      2. Trigger time in a single day: Specify the trigger time and number of instances and click add. The configuration takes effect on a daily basis.
        Notice
        • If the specified trigger time has passed, the configuration takes effect in the next cycle.
        • The interval between two trigger events must be greater than 10 minutes.
      3. Keep the number of instances after: the number of instances to retain after the auto scaling policy is enabled. Specify a value that ranges from 0 to 50.
        Note We recommend that you set the Keep the number of instances after parameter to a value that ranges from the value of the Minimum number of application instances parameter to the value of the Maximum number of application instances parameter. If you set a value that is beyond the value range, the message The number of timed triggers to keep the number of instances has exceeded the range of the maximum and minimum number of instances appears when you save the auto scaling policy. However, the auto scaling policy is still saved.
    • Application indicator trigger
      1. Index name: You can select Average number of requests per second provided by applications, Average response time of services provided by applications (milliseconds), Application average CPU usage, or Application average memory usage.
      2. Target Value: Set the expected value of the monitoring index. The system automatically adds or removes instances so that the index value of your application can reach a value that is nearest to the expected value.
        Note If the index value of your application is smaller than the expected value, the system automatically removes instances. If the index value of your application is greater than the expected value, the system automatically adds instances.
    the way Select a mode to run the trigger. Valid values:
    • Observation only: only observes the index value. When the expected value is reached, an event is sent to Event Center but auto scaling is not triggered.
    • Observe and scale: observes the index value. When the expected value is reached, an event is sent to Event Center, and auto scaling is triggered.
    Note If you select Average CPU utilization or Average memory usage as an index, you cannot select a mode to run the trigger.
  6. Set the Maximum number of application instances and Minimum number of application instances parameters.
    • Maximum number of application instances: Specify a value that ranges from 2 to 1000. After the trigger conditions are met, the system automatically scales out the application. This parameter specifies the maximum number of application instances for auto scaling.
    • Minimum number of application instances: Specify a value that ranges from 0 to 1000. After the trigger conditions are met, the system automatically scales in the application. This parameter specifies the minimum number of application instances for auto scaling.
    Note
    • When multiple triggers are met, the system checks the number of expected instances configured for each trigger and selects the maximum as the number of expected instances for the application.
    • If the expected number of instances is greater than the current number of instances, EDAS scales out the application. The number of instances does not exceed the value of the Maximum number of application instances parameter. If the expected number of instances is smaller than the current number of instances, EDAS scales in the application. The number of instances is not smaller than the value of the Minimum number of application instances parameter.
    • The value of the Minimum number of application instances parameter cannot be equal to that of the Maximum number of application instances parameter.
    • We recommend that you set the Minimum number of application instances and Maximum number of application instances parameters so that the current number of instances falls between. If the current number of instances is beyond the value range, the message The number of timed triggers to keep the number of instances has exceeded the range of the maximum and minimum number of instances appears when you save the auto scaling policy. However, the auto scaling policy is still saved.
  7. After the preceding configuration is complete, click save.
  8. In the upper-right corner of the Auto Scaling page, click Enable.
    After auto scaling is triggered, EDAS scales out or scales in the application based on the auto scaling policy. This also indicates that auto scaling is successful.

Verify the result

After the auto scaling policy is enabled, EDAS automatically scales out or scales in the application based on the auto scaling policy. You can perform the following steps to view the details of auto scaling events:

  1. In the upper-right corner of the Auto Scaling page, click Event.
  2. In the upper-right corner of the Event Center page, set the time range to query events.
  3. On the Event Center page, click the General View tab.
  4. On the Normal View tab, select k8s event from the Event Source drop-down list, select ScalingReplicaSet or DryRunSuccessfulReScale from the Event Type drop-down list, and then click Search.
    • ScalingReplicSet: the events that are generated in Observe and scale mode. You can view the details of the auto scaling events.
    • DryRunSuccessfulReScale: the events that are generated in Observation only mode. In this mode, auto scaling is not triggered.
    Auto Scaling events

What to do next

After an auto scaling policy is enabled, you can delete, disable, or edit the policy. You can also enable a disabled policy or manage your application.

Note After an auto scaling policy is enabled, you cannot stop, start, or manually scale out or scale in your application. If you want to perform these operations, disable the auto scaling policy.