Updated on 2022-02-22 GMT+08:00

Creating an AS Policy

Scenarios

You can manage instances in an AS group through AS policies. This section describes how to create an AS policy.

Creating an Alarm Policy

  1. Log in to the management console.
  1. Under Computing, click Auto Scaling. In the navigation pane on the left, choose Instance Scaling.
  2. Locate the row containing the target AS group and click View AS Policy in the Operation column.
  3. On the AS Policies page, click Add AS Policy.
  4. Set the parameters listed in Table 1.
    Table 1 AS policy parameters

    Parameter

    Description

    Example Value

    Policy Name

    Specifies the name of the AS policy to be created.

    as-policy-p6g5

    Policy Type

    Select Alarm.

    Alarm

    Alarm Rule

    Specifies whether a new alarm rule is to be created (Create) or an existing alarm rule will be used (Use existing).

    For details about how to use an existing alarm rule, see Setting Monitoring Alarm Rules.

    If you choose to create an alarm, system monitoring and custom monitoring are supported.

    • System monitoring requires the parameters in Table 2.
    • Custom monitoring requires the parameters in Table 3.

    N/A

    Scaling Action

    Specifies an action and the number or percentage of instances.

    The following scaling action options are available:
    • Add

      Adds instances to an AS group when the scaling action is performed.

    • Reduce

      Removes instances from an AS group when the scaling action is performed.

    • Set to

      Sets the expected number of instances in an AS group to a specified value.

    • Add 1 instance
    • Add 10% instances

      The number of instances to be added is 10% of the current number of instances in the AS group. If the product of the current number of instances and the percentage is not an integer, AS automatically rounds the value up or down:

      • Rounds down the value that is greater than 1. For example, value 12.7 is rounded down to 12.
      • Rounds up the value that is greater than 0 and less than 1 to 1. For example, value 0.67 is rounded up to 1.

      For example, there are 10 instances in an AS group, and the scaling action is Add 15% instances. When the AS policy is triggered, AS calculates the number of instances to be added is 1.5 and rounds 1.5 down to 1. After the scaling action is complete, there are 11 instances in the AS group.

    Cooldown Period

    To prevent the alarm policy from being frequently triggered, you must set the cooldown period.

    A cooldown period specifies a period of time in the unit of second after each scaling action is complete.

    During the cooldown period, scaling actions triggered by alarms will be denied. Scheduled and periodic scaling actions are not restricted.

    For example, the cooldown period is set to 300 seconds, a scheduled policy is specified to trigger a scaling action at 10:32, and a previous scaling action triggered by a alarm policy ends at 10:30. Any alarm-triggered scaling action will be denied during the cooldown period from 10:30 to 10:35, but scheduled scaling actions will still be triggered at 10:32. If the scheduled scaling action ends at 10:36, a new cooldown period starts from 10:36 and ends at 10:41.

    NOTE:
    • If a scaling action is triggered by an AS policy, the cooldown period is that which is configured for that AS policy.
    • If a scaling action is triggered by manually changing the expected number of instances or by other actions, the cooldown period is that which is configured for the AS group. The default cooldown period is 300 seconds.

    300

    Table 2 System monitoring parameters

    Parameter

    Description

    Example Value

    Alarm Rule Name

    Specifies the name of the alarm rule.

    as-alarm-7o1u

    Monitoring Type

    Specifies the type of monitoring metrics, which can be System monitoring or Custom Monitoring. Select System monitoring.

    System monitoring

    Trigger Condition

    Select monitoring metrics supported by AS and set alarm conditions for the metrics.

    CPU Usage Max. >70%

    Monitoring Interval

    Specifies the interval at which the alarm status is updated based on the alarm rule.

    5 minutes

    Consecutive Occurrences

    Specifies the number of sampling points when an alarm is triggered. If Occurrences is set to n, the sampling points of the alarm rule are the sampling points in n consecutive sampling periods. Only if all the sampling points meet the threshold configured for the alarm rule will the alarm rule status be refreshed as the Alarm status.

    3

    Table 3 Custom monitoring parameters

    Parameter

    Description

    Example Value

    Rule Name

    Specifies the name of the alarm rule.

    as-alarm-7o1u

    Monitoring Type

    Select Custom monitoring. Custom monitoring meets monitoring requirements in various scenarios.

    Custom monitoring

    Resource Type

    Specifies the name of the service for which the alarm rule is configured.

    AGT.ECS

    Dimension

    Specifies the metric dimension of the alarm rule.

    instance_id

    Monitored Object

    Specifies the resources to which the alarm rule applies.

    N/A

    Trigger Condition

    Select monitoring metrics supported by AS and set alarm conditions for the metrics.

    CPU Usage Max. >70%

    Monitoring Interval

    Specifies the interval at which the alarm status is updated based on the alarm rule.

    5 minutes

    Consecutive Occurrences

    Specifies the number of sampling points when an alarm is triggered. If Occurrences is set to n, the sampling points of the alarm rule are the sampling points in n consecutive sampling periods. Only if all the sampling points meet the threshold configured for the alarm rule will the alarm rule status be refreshed as the Alarm status.

    3

  5. Click OK.

    The newly added AS policy is displayed on the AS Policy tab. In addition, the AS policy is in Enabled state by default.

Creating a Scheduled or Periodic Policy

  1. Log in to the management console.
  1. Under Computing, click Auto Scaling. In the navigation pane on the left, choose Instance Scaling.
  2. Locate the row containing the target AS group and click View AS Policy in the Operation column.
  3. On the AS Policies page, click Add AS Policy.
  4. Configure the parameters listed in Table 4.
    Table 4 Parameter description

    Parameter

    Description

    Example Value

    Policy Name

    Specifies the name of the AS policy to be created.

    as-policy-p6g5

    Policy Type

    Select Scheduled or Periodic for expanding resources at a specified time.

    If you select Periodic, you are required to configure two more parameters:

    • Interval
      • One day
      • One week
      • One month
    • Time Range

      Specifies a time range during which the AS policy can be triggered.

    N/A

    Time Zone

    The default value is GMT+08:00.

    GMT+08:00, Beijing, China time, is 8:00 hours ahead Greenwich Mean Time.

    GMT+08:00

    Triggered At

    Specifies a time at which the AS policy is triggered.

    N/A

    Scaling Action

    Specifies an action and the number of instances.

    The following scaling action options are available:
    • Add

      Adds instances to an AS group when the scaling action is performed.

    • Reduce

      Removes instances from an AS group when the scaling action is performed.

    • Set to

      Sets the expected number of instances in an AS group to a specified value.

    • Add 1 instance
    • Add 10% instances

      The number of instances to be added is 10% of the current number of instances in the AS group. If the product of the current number of instances and the percentage is not an integer, AS automatically rounds the value up or down:

    • Rounds down the value that is greater than 1. For example, value 12.7 is rounded down to 12.
    • Rounds up the value that is greater than 0 and less than 1 to 1. For example, value 0.67 is rounded up to 1.

    For example, there are 10 instances in an AS group, and the scaling action is Add 15% instances. When the AS policy is triggered, AS calculates the number of instances to be added is 1.5 and rounds 1.5 down to 1. After the scaling action is complete, there are 11 instances in the AS group.

    Cooldown Period

    To prevent the alarm policy from being frequently triggered, you must set the cooldown period.

    Specifies a period of time after each scaling action is complete.

    During the cooldown period, scaling actions triggered by alarms will be denied. Scheduled and periodic scaling actions are not restricted.

    For example, the cooldown period is set to 300 seconds, a scheduled policy is specified to trigger a scaling action at 10:32, and a previous scaling action triggered by a alarm policy ends at 10:30. Any alarm-triggered scaling action will be denied during the cooldown period from 10:30 to 10:35, but scheduled scaling actions will still be triggered at 10:32. If the scheduled scaling action ends at 10:36, a new cooldown period starts from 10:36 and ends at 10:41.

    NOTE:
    • If a scaling action is triggered by an AS policy, the cooldown period is that which is configured for that AS policy.
    • If a scaling action is triggered by manually changing the expected number of instances or by other actions, the cooldown period is that which is configured for the AS group. The default cooldown period is 300 seconds.

    300

  1. Click OK.

    The newly added AS policy is displayed on the AS Policy tab. In addition, the AS policy is in Enabled state by default.

If you have created scheduled or periodic AS policies that are triggered at the same time, AS will execute the one created later. This constraint does not apply to alarm-triggered AS policies.