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 Kubernetes clusters and serverless Kubernetes clusters in Enterprise Distributed Application Service (EDAS).

Scenario

Applications such as the Internet and game applications are prone to sudden traffic surges during promotional activities. The difficulty in 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 Container Service Kubernetes 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 properly running.
  • If the Kubernetes cluster version is V1.15.0 or later, auto scaling can be triggered when one of the triggers is properly running. When multiple triggers are properly running, the system calculates the desired number of application instances by using the max() function. The following function is used: Desired number of application instances = max(Desired number of application instances defined in Trigger 1, Desired number of application instances defined in Trigger 2, ..., Desired number of application instances defined in Trigger N)
Notice
  • After an auto scaling policy is enabled, you cannot stop, start, or manually your application. If you want to perform these operations, disable the auto scaling policy.
    • Assume that a service is added to an application and a Server Load Balancer (SLB) instance is bound to the application. When auto scaling occurs, EDAS automatically adds application instances that are scaled out to a list of backend servers and removes application instances that are scaled in from the list.
    • Assume that persistent storage is configured for an application. When auto scaling occurs, EDAS automatically associates application instances that are scaled out with the configured persistent storage.
  • You cannot add an auto scaling policy when you perform application changes, such as application deployment, application scaling, and specification changes.
  • 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 Container Service for Kubernetes (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, and click Add Flexible Strategy.
    You can also perform the following operations: In the upper-right corner of the Application Overview page, choose Scale > Auto Scaling, and 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. On 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 contain 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 elapsed, the configuration takes effect 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 Keep the number of instances after to a value that ranges from Minimum number of application instances to Maximum number of application instances. If you set a value that is beyond the value range, the message The number of instances to retain is beyond the value range 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 requests per second, Average response time (ms), Average CPU utilization, or Average memory usage.
      2. Target Value: Set the desired value of the monitoring index. The system automatically scales out or scales in the instances so that the index value of your application can reach a value that is nearest to the desired value.
        Note When the index value of your application is smaller than the desired value, the system automatically scales in the instances. When the index value of your application is greater than the desired value, the system automatically scales out the instances.
    the way Select a mode to run the trigger. Valid values:
    • Observation only: observes the index value only. When the desired 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 desired 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. Configure Maximum number of application instances and Minimum number of application instances.
    • Maximum number of application instances: Specify a value that ranges from 2 to 50. After the trigger conditions are met, the system automatically scales out application instances. 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 50. After the trigger conditions are met, the system automatically scales in application instances. This parameter specifies the minimum number of application instances for auto scaling.
    Note
    • When multiple triggers are properly running, the system calculates the desired number of application instances by using the max() function. The following function is used: Desired number of application instances = max(Desired number of application instances defined in Trigger 1, Desired number of application instances defined in Trigger 2, ..., Desired number of application instances defined in Trigger N)
    • If the desired number of instances is greater than the current number of instances, EDAS scales out application instances. The number of instances will not exceed Maximum number of application instances. If the desired number of instances is smaller than the current number of instances, EDAS scales in application instances. The number of instances will not be smaller than Minimum number of application instances.
    • Minimum number of application instances cannot be equal to Maximum number of application instances.
    • We recommend that the current number of instances is within the value range of Minimum number of application instances and Maximum number of application instances. If the current number of instances is beyond the value range, the message The number of running application instances is beyond the value range 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 application instances 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 application instances 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. On the K8s Events tab of the Event Center page, you can view all the events.
  3. Select ScalingReplicSet or DryRunSuccessfulReScale from the Cause drop-down list. You can view all the auto scaling events.
    • ScalingReplicSet: The events are generated in Observe and scale mode. You can view the details of the auto scaling events.
    • DryRunSuccessfulReScale: The events are generated in Observation only mode. In this mode, auto scaling is not triggered.

More information

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.