Please enable JavaScript.
Coggle requires JavaScript to display documents.
8.83: Auto Scaling Group (ASG) - Coggle Diagram
8.83
: Auto Scaling Group (ASG)
Goal
Scale out (Add EC2 instance) to match increase load
Scale in ( remove EC2 instance) to match decrease load
Ensure have min and max number of EC instance
Auto regis new instance into LB
Recreate an EC2 instance in case prev one is terminated
Features
Launch template
AMI + Instance type
EC2 User Data
EBS volume
Security Group
SSH key pair
IAM roles for your EC2 instance
Network + Subnet information
Load balancer information
Min Size / Max Size / Initial Capacity
CloudWatch Alarms & Scaling
An alarm monitors a metric (Ex Average CPU or customer metric)
Metrics such as Average CPU are computed for overall ASG instances
Can create scale out or in policies
8.85: Dynamic Scaling Policy
Target Tracking Policy
Most simple, easy to setup
Ex: I want average ASG CPU stay around 40%
Simple and step scaling
When CloudWatch alarm is triggered (Ex CPU average > 70%) then add 2 units
When CloudWatch alarm is triggered (Ex CPU average < 30%) then remove 1 unit
Schedule action
Anticipate scaling based on known usage pattern
Ex: Increase min capacity to 10 at 5pm on Friday
8.85: Predictive scaling
Continous forecast load and schedule scaling ahead
Good metric to scale
CPUUtilization
Average CPU across your instance
Request count per target
make sure the number of EC2 request is stable
Average network in/out
If your app is network bound
Custom metric
That you put on CloudWatch
Scaling cooldown
After scaling activity, you are in cooldown period (default 300s)
During cooldown period, ASG will not launch or terminate any instance (to allow metric stabilize)
Advice: use ready-to-use AMI to reduce config time to serve request faster and reduce cooldown period