Fane
Fane

Reputation: 2076

How exactly does Auto Scaling in AWS work?

I read the docs but still didn't understand anything. The AWS forum takes time to answer. Here is my scenario:

I had code in an EC2 instance but needed to join the instance to a scaling group. There was one already created so I just joined mine to that since it was "unused". In a moment notice my instance terminates and I lost all my code within the instance. Only the original instance from the scaling group maintained itself.

Now my question: Is scaling supposed to help the same service performance? Because:

This means I can SSH to one but if I SSH to another one will there be the same code?

So, between trying to understand if need to try and recover my terminated EC2 instance and understanding all this process, I must admit I'm quite lost because nothing really inspires "merely incrementing process power" with confidence so I really don't know what to do.

Upvotes: 1

Views: 1999

Answers (2)

John Rotenstein
John Rotenstein

Reputation: 269400

Sorry to hear that you lost valuable information. One thing to learn about Auto Scaling is that instances can be terminated, so they should be designed with this in mind.

Purpose of Auto Scaling

Auto Scaling is designed to dynamically adjust the number of instances in an auto scaling group to handle a given compute/processing requirement. Instances can be automatically added when things are busy, and terminated when things are less busy.

Auto Scaling automatically creates new instances by using a Launch Configuration, which describes the type of instance to launch, which disk image (AMI) to use, security group, network settings, startup script, etc. Each new instance would, of course, receive its own private IP address and (if configured) its own public IP address.

The idea is that a new instance can be started with no manual intervention, and all instances within an Auto Scaling group would normally be configured identically (since they are doing an identical job).

When an instance is no longer required, the group is "scaled-in", meaning that an instance is terminated. All data on the instance is lost. (Actually, disks can be kept around after termination, but they are a pain to handle later, so it is best not to do this.)

It's okay for instances to be terminated because they can easily be recreated when Auto Scaling launches a new instances. Unfortunately in your case, you added an instance to an existing Auto Scaling group with your own configuration. It would therefore be your responsibility to make sure you can handle the loss of the instance. It's quite unusual to manually add an instance to an existing Auto Scaling group -- usually it's to send some traffic to a test instance or for doing A/B trials.

Why did it terminate?

The scaling policies attached to your Auto Scaling group probably decided that you had too much capacity (as a result of increasing the number of instances), and therefore decided to terminate an instance.

Recovering your terminated instance

Your terminated instance cannot be "recovered", but there is a small possibility that your disk is still available. By default, when launching an Amazon EC2 instance, boot disks are marked as Delete on Termination, but additional disks default to not deleting on termination. Therefore, if your code was on the non-boot disk, it may still be available in your Volumes tab.

If, however, your code was on a disk volume that was deleted, then the contents cannot be recovered. (Well, if you have Support, you could ask them but it's unlikely to be easy, especially if time has passed since deletion.)

See: AWS Auto Scaling documentation

Upvotes: 6

datasage
datasage

Reputation: 19563

The short answer. Autoscaling uses horizontal scaling (adding more instances) and not vertical scaling (increasing CPU/memory allotment)

In order to successfully use auto scaling, you need to design your application using the principle of shared nothing architecture. No persistent data can be stored on the instance itself. Instead you would store it on S3, or other instances not part of autoscaling group.

Upvotes: 5

Related Questions