BT

AWS Adds Hooks Into Expanded Auto Scaling Lifecycle

| by Steffen Opel Follow 4 Followers on Sep 30, 2014. Estimated reading time: 3 minutes |

Amazon Web Services recently added several features to its Auto Scaling service to improve control over the managed Amazon EC2 instances. It is now possible to hook into the pending and terminating lifecycle state transitions to perform custom operations, which is also available for in service instances by means of a new standby state. The new DetachInstances API action now allows to remove instances from an Auto Scaling group.

Auto Scaling is a key AWS component for building "resilient, highly scalable applications that react to changes in load by launching or terminating Amazon EC2 instances as needed" according to conditions based on Amazon CloudWatch metrics. Besides many built in AWS metrics, CloudWatch also offers publishing of custom metrics and enables freely definable Auto Scaling conditions in turn.

Main use cases for Auto Scaling strategies are policy or schedule based scaling in and out on demand for cost control and operational flexibility, and health status check based replacement of unhealthy EC2 instances. Auto Scaling is available as a standalone service and also backing all AWS application management services like AWS CloudFormation, AWS Elastic Beanstalk and AWS OpsWorks, where it can be instrumented via the respective service configuration layers.

AWS Auto Scaling Basic Diagram

Auto Scaling already offered Amazon SNS based notifications about its lifecycle transitions, though any custom actions performed in reaction to these notifications only applied after the transitions themselves completed. Creating lifecycle hooks via the PutLifecycleHook API action now allows to request the pending and terminating transitions to be paused until the user has performed whatever custom action is desired and then confirmed the transition to proceed via the CompleteLifecycleAction API action.

AWS describes the resulting order of events as follows:

  1. Auto Scaling responds to a scale in or scale out event by launching or terminating an instance.
  2. Auto Scaling puts the instance into a wait state. The state of the instance becomes either 'Pending:Wait' or 'Terminating:Wait'.
  3. Auto Scaling sends a message to the notification target defined for the lifecycle hook. The message contains information about the instance that is launching or terminating, and a token you can use to control the lifecycle action.
  4. At this point, the instance remains in a wait state until you manually instruct Auto Scaling to continue or when the timeout value for the lifecycle hook expires.

Instances can be kept in either of the temporary 'Wait' states for a maximum of 48 hours by means of the RecordLifecycleActionHeartbeat API action (the default timeout is one hour).

Similar to 'Wait' and 'Proceed' for the 'Pending' and 'Terminating' states, AWS now also allows to temporarily move instances from the 'InService' state to a new 'Standby' state and back again in order to perform maintenance or troubleshooting operations. While in standby, the instance will be deregistered from an Elastic Load Balancer associated with the Auto Scaling group, if any.

AWS lists some typical use cases for each of the three main instance states:

While installing software to pending instances has been available and widely used before (e.g. by passing user data to EC2 instances), the new 'Pending:Wait' state enables scenarios where manual interaction is required. More importantly, the 'Terminating:Wait' state now allows inspection of terminating instances, which hadn't been possible before at all.

Finally, the DetachInstances API action has been added too, complementing the AttachInstances API action that has been introduced together with the option to Create Auto Scaling Groups from Running Amazon EC2 Instances in January 2014. These methods enable a variety of custom provisioning scenarios like moving instances from one Auto Scaling group to another or providing an instance factory, from which readily provisioned instances can be detached for requesting users without the otherwise incurred startup delay for example.

The Auto Scaling API reference summarizes all API actions, more detailed explanations are available in the developer guide. They can be used directly via the AWS Command Line Interface and the AWS Tools for Windows PowerShell and programmatically via the various AWS SDKs. Support for Auto Scaling related topics is provided in the Amazon Elastic Compute Cloud (EC2) forum.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

ElasticBeanstalk rolling updates by Danilo Tuler

I hope this enables a more decent zero downtime rolling update feature to ElasticBeanstalk

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

1 Discuss
BT