All Products
Search
Document Center

Auto Scaling:Overview of best practices for lifecycle hooks and OOS templates

Last Updated:Dec 28, 2023

You can set the notification method to OOS Template and specify a CloudOps Orchestration Service (OOS) template when you create a lifecycle hook in a scaling group. During scaling activities, ECS instances in the scaling group are put into the wait state and then OOS performs the operations and maintenance (O&M) operations specified in the OOS template on the ECS instances.

Lifecycle hooks

After scaling activities are triggered, Auto Scaling automatically completes the scaling activities. For more information about changes of ECS instance service states, see Instance lifecycles.

Lifecycle hooks can be used to put ECS instances into the wait state during scaling activities. After OOS performs customized operations on the instances, these instances are put out of the wait state or released. For example, OOS can bind secondary elastic network interfaces (ENIs) to ECS instances and add the instances to the whitelists of the associated ApsaraDB for Redis instances during scale-out events, and copy logs and clear data during scale-in events.

When ECS instances are put into the wait state, Auto Scaling notifies OOS to perform the customized O&M operations specified in the template.

OOS templates

OOS is an automated O&M service provided by Alibaba Cloud, which helps you manage and execute O&M tasks. You can define execution tasks, the order in which to execute the tasks, input parameters, and output parameters in templates and use these templates to automate O&M tasks. For more information, see Introduction to OOS.

The following section describes the benefits of using OOS templates to respond to lifecycle hook notifications:

  • OOS templates are a collection of O&M operations, which help you implement complex O&M processes.

  • Notifications of lifecycle hooks automatically trigger O&M operations without the need to manually resolve content of the notifications.

  • Public templates are provided to help you perform common O&M operations with ease. For more information, see Public templates.

  • Custom templates are supported. For more information, see Create a Template.

Automated O&M processes

The following figure shows how to implement an automated O&M process by using a lifecycle hook and an OOS template.Integrated usage

The following section describes the process:

  1. ECS instances are put into the wait state and enter the Pending:Wait state.

  2. Auto Scaling notifies OOS to perform the customized O&M operations specified in the template.

  3. Complete the process based on the following execution results:

    • If the O&M operations succeed, the ECS instances are put out of the wait state and the scaling activity continues. If the scaling activity is a scale-out event, the event continues and the ECS instances are added to the scaling group. If the scaling activity is a scale-in event, the event continues and the ECS instances are removed from the scaling group.

    • If the O&M operations fail, the ECS instances are put out of the wait state and the scaling activity ends. If the scaling activity is a scale-out event, the ECS instances are released. If the scaling activity is a scale-in event, the event is not affected and the ECS instances are still removed from the scaling group.

O&M practices

The following table describes how to use OOS public templates.

Public template name

Applicable scaling activity type

Description

Reference

ACS-ESS-LifeCycleApplyAutoSnapshotPolicy

Scale-out events

Use lifecycle hooks to apply automatic snapshot policies to disks.

Apply an automatic snapshot policy to ECS instances

ACS-ESS-LifeCycleRunCommand

Scale-in and scale-out events

Use lifecycle hooks to run commands on ECS instances.

Automatically execute scripts on ECS instances

ACS-ESS-LifeCycleModifyPolarDBIPWhitelist

Scale-in and scale-out events

Use lifecycle hooks to configure the whitelists of PolarDB clusters.

Automatically add or remove the private IP addresses of ECS instances to or from the IP address whitelist of a PolarDB cluster

ACS-ESS-LifeCycleModifyRedisIPWhitelist

Scale-in and scale-out events

Use lifecycle hooks to configure the whitelists of ApsaraDB for Redis instances.

Automatically add or remove the private IP addresses of ECS instances to or from the IP address whitelist of an ApsaraDB for Redis instance

ACS-ESS-LifeCycleModifyMongoDBIPWhitelist

Scale-in and scale-out events

Use lifecycle hooks to configure the whitelists of ApsaraDB for MongoDB instances.

Automatically add or remove the private IP addresses of ECS instances to or from the IP address whitelist of a MongoDB instance

ACS-ESS-LifeCycleModifyAnalyticDBIPWhitelist

Scale-in and scale-out events

Use lifecycle hooks to configure the whitelists of AnalyticDB for MySQL clusters.

Automatically add or remove the private IP addresses of ECS instances to or from the IP address whitelist of an AnalyticDB for MySQL cluster

ACS-ESS-LifeCycleAttachNASFileSystemToInstance

Scale-out events

Use lifecycle hooks to mount NAS file systems to ECS instances.

Mount NAS file systems to ECS instances

ACS-ESS-LifeCycleCreateNetworkInterfaceAndEipAndAttachToInstance

Scale-out events

Use lifecycle hooks to create secondary ENIs and EIPs, associate the EIPs with the secondary ENIs, and bind the secondary ENIs to ECS instances.

Automatically bind secondary ENIs to ECS instances

ACS-ESS-LifeCycleDetachNetworkInterfaceAndDeleteEip

Scale-in events

Use lifecycle hooks to unbind secondary ENIs from ECS instances and release the secondary ENIs and their associated EIPs.

Automatically unbind secondary ENIs from ECS instances

ACS-ESS-LifeCycleAllocateEipAddressAndAttachToInstance

Scale-out events

Use lifecycle hooks to create EIPs and associate the EIPs with ECS instances.

Automatically associate EIPs with ECS instances

ACS-ESS-LifeCycleReleaseEipAddressFromInstance

Scale-in events

Use lifecycle hooks to disassociate EIPs from ECS instances and release the EIPs.

Enable the automatic release feature for an EIP