Home » Blog

Auto Scaling with the AWS Management Console

 |  Post a comment

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.

AWS_Auto_Scaling_using_EC2_Management_Console

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.

Welcome to AS Wizard
The Welcome Screen

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

Welcome to AS Step 1

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:

Create Launch Configuration: Choosing the AMI
Create Launch Configuration: Choosing the AMI

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.

Create Launch Configuration: Details Tab
Create Launch Configuration: Details Tab

As optional we can pick Spot Instances (choosing the maximum price we are willing to pay):

Create Launch Configuration: Details Tab – Choosing SPOT Instances
Create Launch Configuration: Details Tab – Choosing SPOT Instances

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:

Create Launch Configuration: Add Storage Tab
Create Launch Configuration: Add Storage Tab

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:

Create Launch Configuration: Configuring the Security Group
Create Launch Configuration: Configuring the Security Group

Last tab let us to review and eventually change previous choices:

Create Launch Configuration: Final Review
Create Launch Configuration: Final Review

After pressing the Create launch configuration button we’ve to choose the key pair to access our instances:

Create Launch Configuration: Selecting the access Key Pair
Create Launch Configuration: Selecting the access Key Pair

Step 2: Create Auto Scaling Group

Welcome to AS Step 2

We’re ready to create our Scaling Group, first tab will bring us a few choices:

Create Auto Scaling Group: Initial setup
Create Auto Scaling Group: Initial setup

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:

Create Auto Scaling Group: Choosing networking type in EC2 Classic
Create Auto Scaling Group: Choosing networking type in EC2 Classic

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.

Create Auto Scaling Group: Choosing networking type in EC2-VPC-Only
Create Auto Scaling Group: Choosing networking type in EC2-VPC-Only

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:

Create Auto Scaling Group: Initial setup - Advanced Details
Create Auto Scaling Group: Initial setup – Advanced Details

The second tab allows to choose between two fundamental scaling plans:

Create Auto Scaling Group:  Choosing Auto Scaling Policy
Create Auto Scaling Group: Choosing Auto Scaling Policy

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:

Create Auto Scaling Group:  Creating Scale Policy
Create Auto Scaling Group: Creating Scale Policy

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:

Create Auto Scaling Group:  Creating Scale Alarm
Create Auto Scaling Group: Creating Scale Alarm

Once added the alarm our Increase Group Size policy will look like this:

Create Auto Scaling Group:  Scale Policy applied
Create Auto Scaling Group: Scale Policy applied

We’ll add the scale down policy later, now it’s time to configure the notifications relative to our group:

Create Auto Scaling Group: Configuring Notifications
Create Auto Scaling Group: Configuring Notifications

The last tab allow us to review and eventually edit our configuration:

The last tab allow us to review and eventually edit our configuration: Final Review
The last tab allow us to review and eventually edit our configuration: Final Review

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.

Create Auto Scaling Group: Rolling out
Create Auto Scaling Group: Rolling out

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:

Create Auto Scaling Group: Editing Decrease Group Size policy
Create Auto Scaling Group: Editing Decrease Group Size policy

Create Auto Scaling Group: Creating Group Decrease policy using CW metrics
Create Auto Scaling Group: Creating Group Decrease policy using CW metrics

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:

Create Auto Scaling Group: Decrease policy applied
Create Auto Scaling Group: Decrease policy applied

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:

Final Cleaning
Cleaning everything up

References:
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

Post a comment


6 + = 11