Introduction
Steps to create auto scaling (A.S), two main concepts
- Configuration
What
to scale out- Instance settings related
- Scaling groups
Where
to scale out:VPC, subnet, LB etcHow many
andwhat condition
to scale:Scaling policies
Create A.S Configuration
- Select AMI
- Select instance type
- Configure details
- Select storage
- Select security group (S.G)
- Select pem
- Completed view
Create A.S Group
- Select the source configuration for A.S group
- Configure details
- Configure scaling policies, which can be set here or later
- Configure notification here or later
- Configure tags which will auto tag instance when scaling out
Result
Right after setting up, A.S is creating an new instance due to the difference between desired and current instance quantity. Click Edit
to modify any setting accordingly
Clink Instance
tag to view instances and its condition under this A.S
Confirm the instance status by checking the EC2 service main section
Check A.S Activity History
to understand what A.S has done
Configure Scaling Policy
Click Add policy
under Scaling Policies
tag, click Create simple scaling
policy
Give a name and set take the action
, which is to add an instance.
Condition, Execute policy when
, can be set here but we will set it later elsewhere.
Repeat the step to create an action
to decrease an instance.
Completed view of Scaling policies. Notice that the Execute policy when
has not been set yet, which we will do it elsewhere later.
Create Alarm under CloudWatch (C.W)
Create alarms under C.W to monitor certain condition of instances and trigger action created on steps above when condition is met
In this example we will monitor the metrics in A.S group
Select the metric to monitor, in this case, CPUUtilization is selected
Set the condition to be triggered
Whenever
section is the place to set the condition
Actions
section is the place to set what to do when condition is met. In this case, we want to scale out when condition is met, so delete the default action which is SNS notification and click on AutoScaling Action
Period
is the time range to be monitor
Completed view. This configuration is saying
- In every 1 minute monitored data point
- If any monitored data point, wich is CPUUtilization, is more than 50%
- Execute
Actions
, which is the scale policy action created in A.S group
Repeat the step to create a monitor policy to decrease instance when CPUUtilization is lower then 30%
Completed view of two alarms
CPUUtilization is lower then 30% so lowCPU is in alarm state
Go back to Scaling Policies
under A.S, the Execute policy when
section has the condition information now which is the settings did in C.W
A.S Testing
- Increase instance CPU loading
- A.S responds to high CPU loading
- Checking C.W. highCPU alarm is triggered so it executes the
scaling policy
set in A.S group
- Checking scaling policy in A.S.