Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Here is the scenario, there are multiple EC2 instances behind a load balancer. When traffic dies down, the SCALE_DOWN policy is triggered from a CloudWatch alarm. What I would like, is for the instance that is going to be terminated, or a separate server altogether, to be able to run a quick script that will execute a few commands to ensure all data has been transferred.

My initial question was going to be how can I send a notification when an instance is going to be terminated by an auto scale, SCALE_DOWN policy. But then I saw this question Amazon EC2 notifying the instance when the autoscale service terminates it.

If the notification is sent, how much time is there before the instance actually gets terminated? Are there any parameters to specify this time?

Would it be a better idea to notify an instance that it is no longer needed, and get the instance to terminate itself once it has finished running the final script?

Or, am I making this into a bigger problem than it actually is, and theres a far simpler solution?

share|improve this question
    
Autoscaling groups only make sense for stateless servers. They should not be storing any data. What happens when one dies without warning, rather than just scaling down? I think you need to rethink your architecture to use shared storage. –  jamieb Dec 10 '12 at 10:50
add comment

1 Answer

When an EC2 instance is going down it is executing the scripts that are attached to this process. Therefore, you have a good chance that your script will be executed before the actual instance termination.

However, it is not guarantee that the script will be executed, and your process should assume that some of its instances will be terminated without performing it.

There are many reasons for the termination to be "unsuccessful", and given it any time threshold can't change that fact, maybe reduce its frequency.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.