Event-triggered tasks integrate the features of Auto Scaling and CloudMonitor. You can create event-triggered tasks to dynamically manage scaling groups. Similar to scheduled tasks, event-triggered tasks execute specified scaling rules to trigger scaling activities. This way, instances in scaling groups can be automatically scaled.
Introduction
You must specify the metrics that you want to monitor in event-triggered tasks. The system collects the metric data in real time. When the alert conditions are met, the system triggers alerts and executes the specified scaling rules. You can use event-triggered tasks to dynamically adjust the number of instances. This ensures that the changing requirements are met and the metric values are maintained within the expected range. You can create the following types of event-triggered tasks in the Auto Scaling console:
Custom monitoring event-triggered tasks: custom event-triggered tasks. This type of event-triggered task provides a standard method to integrate your custom monitoring system with Auto Scaling, which improves the availability of event-triggered tasks.
Scheduled tasks execute specified scaling rules as scheduled. If your business has obvious patterns or you can predict the peak hours, you can create scheduled tasks to execute scaling rules. For more information, see Overview of scheduled tasks. If your business has an outburst of traffic or you cannot predict the peak hours, scheduled tasks cannot meet your business requirements. In this case, you can create event-triggered tasks to enable flexible execution of scaling rules. Even-triggered tasks monitor your business workloads in real time and trigger the execution of scale-out rules during peak hours to provide more instances and the execution of scale-in rules during off-peak hours to remove excess instances. This allows you to run your business without interruption and minimize resource costs.
Limits
If you do not specify an expected number of instances for your scaling group, Auto Scaling cannot execute other scaling activities for the scaling group when a non-parallel scaling activity is being executed. For more information, see Expected number of instances.
Event-triggered tasks cannot execute scaling rules during the cooldown period.
In most cases, Auto Scaling requires a few minutes to add Elastic Compute Service (ECS) instances or elastic container instances to a scaling group, start the instances, deploy services, and collect metric values. We recommend that you specify the cooldown period based on your business requirements. This way, you can prevent the scaling rules from being repeatedly triggered when the metric data of new instances is missing.
By default, an event-triggered task has a one-minute statistical period. During the minute, no more scaling rules are triggered.
Cron expression
When you create an event-triggered task in the Auto Scaling console, you can set the Effective Period parameter to Cron Expression.
A cron expression is a string that represents a schedule. The string consists of multiple fields that are separated by spaces and describe individual details of the schedule. An event-triggered task supports a cron expression that consists of five fields in the X X X X X
format. X
is a placeholder for a field. The fields in a cron expression represent seconds, minutes, hours, days, and months. Each field can be a definite value or a special character that has logical meaning.
When you configure a cron expression for an event-triggered task, take note of the following items:
Cron expressions are in UTC+0. When you configure a cron expression, you must convert the local time to UTC+0. For example, the time in China is in UTC+8. If you are in China and you want to execute your event-triggered task between 01:00:00 and 02:59:00 every day, you must subtract 8 hours from the time range. In this case, you must set the cron expression to
* * 17-18 * *
.If an alert is triggered outside the effective period of an event-triggered task, the event-triggered task enters the Alert state but does not execute the specified scaling rule.
Field | Required | Value range | Special character |
Second | Yes | 0 to 59 | , - / * |
Minute | Yes | 0 to 59 | , - / * |
Hour | Yes | 0 to 23 | , - / * |
Day | Yes | 1 to 31 | , - / * L W |
Month | Yes | 1 to 12 | , - / * |
Special character | Description | Example |
| All valid field values | In the Month field, an asterisk (*) specifies every month. |
| Enumerated values | In the Minute field, |
| Range values | In the Minute field, |
| Increments | In the Minute field, |
| The L character indicates the last day. Only the Day field supports this character. Note To prevent logic errors, do not specify a list or range when you use the | In the Day field, |
| The W character indicates the weekday that is nearest to the specified day of the month. The workday that the | If |
Cron expression | Description |
| Effective all the time. |
| Effective between 01:00:00 and 01:30:00 and between 02:00:00 and 02:30:00 every day. |
| Effective between 00:00:00 and 00:59:00 and between 02:00:00 and 02:59:00 every day. |
| Effective between 01:00:00 and 01:59:00 every two days staring from the first day of each month. For example, the first two effective time ranges of each month are between 01:00:00 and 01:59:00 on the first day of each month and between 01:00:00 and 01:59:00 on the third day of each month. |
| Effective between 01:00:00 and 01:59:00 on the last day of each month. |
| Effective on different days based on whether the fifth day of each month is a weekday.
|
Manage an event-triggered task
The following table describes the operations that you can perform on event-triggered tasks in different scenarios and provides relevant links.
User guide | Description | API reference |
Create an event-triggered task. | ||
View an event-triggered task. | ||
Modify or delete an event-triggered task. | ||
Disable or enable an event-triggered task. |