Starting this December Amazon added the Auto Scaling Support to its web Console easing the setup of this service to people who just do not like the CLI. Prior to introduce this new component we’ll make a short recap on the Auto Scaling service.
Auto Scaling in AWS
Probably one of the most appreciated features among the many provided by Amazon Web Services. Auto Scaling allow us to scale our computational capacity according to our needs: We can scale out to deal with demand spikes or decrease our EC2 fleet while the demand decreases, seamlessly and automatically, without any external intervention.
As a simple example we can configure an AS group to add instances when the CPU usage of our structure goes above the 70% or when the Latency (measured at Elastic Load Balancer level) crosses our UI usability index: let’s say that time to satisfy an HTTP request passes the 500 millisec threshold.
More details and examples are provided in the Auto Scaling Developer Guide.
Welcome to Auto Scaling
Before December 2013 there was Auto Scaling using the CLI and to create a Launch Configuration we should have typed this:
as create-launch-configuration --launch-configuration-name WebAS --image-id ami-c7c0d6b3 --key-name WebAS-KeyPair --instance-type m1.large --security-groups web ssh monitoring
Now the EC2 console shows another element: AUTO SCALING and we can set up our Auto Scaling platform with the browser.
The welcome page clearly outlines three major benefits of using Auto Scaling: Reuse Instance templates, fully automated provisioning and the possibility of adjust the capacity.
Once started the wizard we’re taken through the successive steps:
Step 1: Creating the launch configuration
In this first step we’re required choose:
The AMI flavor and architecture: all ami are suitable for AS groups, ours, Marketplace’s AMI and community ones:
Instance Type: Where we’ll choose the instance that fits our needs: General Purpose (m1 and m3 families), Memory optimized (m2 family), Storage optimized (hi1.4xlarge or hi1.4xlarge) or Compute optimized (c1 and c3 families)… which characteristics are better described here.
Configuration details: We’re requested to enter our configuration name, an eventual IAM role to assign to the newly created instances. We can also enable CloudWatch detailed monitoring.
An Advanced Details section lets us to choose AMI’s Kernel and Ram Disk and optionally to fill in a User data block.
As optional we can pick Spot Instances (choosing the maximum price we are willing to pay):
Before choosing to run Spot Instances you should read: Managing Spot Instances with Auto Scaling.
Storage options: Defaults to a 8GB root disk but we can change it and add additional volumes with provisioned IOPS too:
Security group: We can choose a pre-existent Security Group or just add a new one like in the image below where we’re restricting SSH access to our IP while leaving HTTP and HTTPS access open to anyone:
Last tab let us to review and eventually change previous choices:
After pressing the Create launch configuration button we’ve to choose the key pair to access our instances:
Step 2: Create Auto Scaling Group
We’re ready to create our Scaling Group, first tab will bring us a few choices:
Group name and size do not require further explications but we have to spend a few words on the Network choice: If our AWS account has been created before April 2013 we can choose to create our Auto Scaling Group either on a VPC or an EC2-Classic environment requiring one more choice: the Availability Zones:
With an EC2-VPC-Only account we can choose an existing VPC and the subnets where launch our AS Group or of course, we can choose to create a new VPC or even add other subnets to a pre-existing VPC.
In the Advanced Details pull down we can add an Elastic Load balancer and select the type of checks to perform on the instances (ELB ones on EC2 Status Checks). We can also tune the period that the ELB waits before starting to check the instances (Health Check Grace Period) according to our needs.
If we want to take advantage of CloudWatch detailed monitoring we have to enable it here:
The second tab allows to choose between two fundamental scaling plans:
Keep this group at its initial size: This policy ensures that our group maintains a number of healthy instances equal to the initial size: as an instance fail checks it will be replaced.
Use scaling policies to adjust the capacity of this group: This policy let us choose on which CloudWatch metrics/alarms increase or decrease our Group size:
We can set the minimum and the maximum number of instances composing our AS group. CloudWatch alarms can be easily added after but we’ll add now the one to permit our group to increase its size as shown below:
Once added the alarm our Increase Group Size policy will look like this:
We’ll add the scale down policy later, now it’s time to configure the notifications relative to our group:
The last tab allow us to review and eventually edit our configuration:
After pressing the Create Auto Scaling Group button we’re taken to a status screen showing the creation of our resources. If something fails you’re prompted to retry the single resource creation.
Once the Auto Scaling group is successfully created we can select it, go to the Scaling Policies tab and edit the Decrease Group Size policy to fit our needs:
In our example we’re requesting a scale down when the group average CPU utilization decreases below the 20% and to avoid spikes, we consider 3 consecutive periods of 1 minute.
After creating the alarm and saving the changes our Decrease Group Size policy will look as in the image below:
Our Auto Scaling Group is ready and fully working: It can scale between 2 and 12 instances using average CPU load. All traffic passes through an Elastic Load Balancer allowing us to monitor the global application heath too.
Our Demo is over, time to clean up:
Amazon Auto Scaling http://aws.amazon.com/autoscaling
Auto Scaling Developer Guide http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide
Amazon Virtual Private Cloud User Guide http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide
EC2 User Guide: Managing Spot Instances with Auto Scaling http://docs.aws.amazon.com/AWSEC2/…/spot-and-autoscaling.html