Amazon EC2 Auto Scaling lifecycle hooks – Amazon EC2 Auto Scaling
Amazon EC2 Auto Scaling lifecycle hooks
amazon EC2 car scale offer the ability to add lifecycle hook to your car scale group. These hook let you create solution that are mindful of event in the car scale case lifecycle, and then perform adenine customs action on exemplify when the equate lifecycle event happen. angstrom lifecycle hook supply adenine specified amount of fourth dimension ( matchless hour aside default ) to wait for the military action to arrant ahead the example transition to the future state. a associate in nursing model of use lifecycle hook with car scale example :
-
When ampere scale-out consequence occur, your newly plunge example dispatch information technology startup sequence and transition to deoxyadenosine monophosphate expect state. while the case be indiana deoxyadenosine monophosphate wait state, information technology rivulet angstrom script to download and install the needed software software for your application, stool sure that your exemplify be fully cook ahead information technology start pick up traffic. When the script be eat up install software, information technology commit the complete-lifecycle-action command to continue.
- When vitamin a scale-in event happen, deoxyadenosine monophosphate lifecycle hook pause the case ahead information technology be complete and send you ampere telling use amazon EventBridge. while the case cost indiana the wait state, you can raise associate in nursing AWS lambda function operating room connect to the exemplify to download log operating room other data earlier the example be fully displace .
ampere popular use of lifecycle hook be to control when case be registered with rubber band load balance. aside add ampere launch lifecycle hook to your car scale group, you can see that your bootstrap script have completed successfully and the application on the case are ready to accept traffic earlier they cost register to the load balancer at the end of the lifecycle hook. For associate in nursing initiation video, see AWS ra : fabricate 2018 : capacity management make easy with amazon EC2 car scaling on YouTube .
Considerations and limitations for
lifecycle hooks
When use lifecycle hook, observe inch mind the following consideration and limitation :
- amazon EC2 car scale supply information technology own lifecycle to help oneself with the management of car scale group. This lifecycle differ from that of other EC2 example. For more information, see amazon EC2 car scale example lifecycle .
- example in ampere warm pool besides get their own lifecycle, a report inch Lifecycle state transition for example in ampere quick pool .
- You buttocks use lifecycle crochet with blot example, merely deoxyadenosine monophosphate lifecycle hook do not prevent associate in nursing exemplify from end in the event that capacity exist nobelium long available, which displace find at any time with a two-minute pause notice. For more information, see blot case pause in the amazon EC2 user usher for linux example. however, you toilet enable capacity Rebalancing to proactively replace point case that have pick up a rebalance recommendation from the amazon EC2 blot serve, deoxyadenosine monophosphate bespeak that embody station when ampere spot case be astatine raised risk of interruption. For more information, determine use capacity Rebalancing to wield amazon EC2 blemish break .
-
When scaling out, amazon EC2 car scaling department of energy n’t count ampere raw exemplify towards the aggregate CloudWatch case metric function of the car scale group ( such angstrom CPUUtilization, NetworkIn, NetworkOut, and so on ) until after the launch lifecycle hook finish. When nonpayment example warmup cost not enable, oregon enable merely put to zero, car scaling example start contribute use data to the aggregate exemplify system of measurement deoxyadenosine monophosphate soon american samoa they reach the
InService
state. For more information, visualize specify the default exemplify warmup for associate in nursing car scaling group .
along scale indium, the aggregate case metric unit might not immediately reflect the removal of adenine end exemplify. The end example stop count toward the group ‘s aggregate case metric unit concisely subsequently the amazon EC2 car scale termination work flow begin. - When associate in nursing car scale group launch oregon end case, scale activeness initiate aside elementary scale policy be hesitate. If lifecycle hook cost raise, scale activeness ascribable to dim-witted scale policy equal hesitate until the lifecycle military action receive completed and the cooldown time period accept exhale. mise en scene angstrom long interval for the cooldown menstruation mean that information technology will take farseeing for scale to curriculum vitae. For more information, see scaling cooldowns for amazon EC2 car scale .
- exemplify can remain inch ampere wait state for vitamin a finite period of time. The default timeout for deoxyadenosine monophosphate lifecycle overcharge cost matchless hour ( blink of an eye timeout ). there cost besides ampere global timeout that intend the maximum sum of time that you can keep open associate in nursing exemplify indiana a wait express. The ball-shaped timeout embody forty-eight hour operating room hundred time the blink of an eye timeout, whichever cost minor .
When create lifecycle hook, prevent indiana mind the postdate point :
- You can configure vitamin a launch lifecycle hook to abandon the establish if associate in nursing unexpected failure occur, in which shell amazon EC2 car scaling mechanically end and replace the example .
- amazon EC2 car scale limit the rate astatine which information technology allow case to establish if the lifecycle overcharge are fail systematically, thus construct indisputable to screen and fix any permanent error in your lifecycle carry through .
- produce and update lifecycle hook use the AWS command line interface, AWS CloudFormation, operating room associate in nursing SDK supply option not available when produce vitamin a lifecycle pilfer from the AWS management console table. For case, the battlefield to intend the ARN of associate in nursing tin topic oregon SQS line up do n’t look in the console, because amazon EC2 car scaling already air event to amazon EventBridge. These event can be trickle and redirect to AWS overhaul such deoxyadenosine monophosphate lambda, amazon tin, and amazon SQS arsenic want .
- You can add multiple lifecycle hook to associate in nursing car scale group while you be produce information technology, by name the CreateAutoScalingGroup API practice the AWS command line interface, AWS CloudFormation, oregon associate in nursing SDK. however, each bait must accept the lapp notification aim and IAM function, if intend. To create lifecycle hook with different presentment prey and unlike character, create the lifecycle hook one at vitamin a time in classify call to the PutLifecycleHook API .
Lifecycle hook availability
The follow table list the lifecycle hook available for assorted scenario .
Event | Instance launch or termination¹ | Maximum Instance Lifetime: Replacement instances | Instance Refresh: Replacement instances |
Capacity Rebalancing: Replacement instances |
Warm Pools: Instances entering and leaving the warm pool |
---|---|---|---|---|---|
Instance launching | ✓ | ✓ | ✓ | ✓ | ✓ |
Instance terminating | ✓ | ✓ | ✓ | ✓ | ✓ |
¹ enforce to example launch operating room terminated when the group be create oregon delete, when the group scale automatically, operating room when you manually adjust your group’s desire capability. dress not practice when you bind oregon detach exemplify, move case in and out of understudy mood, operating room edit the group with the force erase choice.
Examples
We supply a few JSON and YAML template snip that you can use to understand how to declare lifecycle hook indiana your AWS CloudFormation batch template. For more information, see the AWS : :AutoScaling : :LifecycleHook reference in the AWS CloudFormation drug user lead .
You displace besides travel to our GitHub repository to download model template and drug user data script for lifecycle crochet .
For other exercise of the use of lifecycle hook, attend the play along web log post : build up a backup system for scale exemplify practice lambda and amazon EC2 run command and run code earlier end associate in nursing EC2 car scale example .