EC2 Auto Scaling Groups
Sets scaling rules which will automatically launch additional EC2 instance or shutdown instances to meet current demand
Auto Scaling Groups (ASG) contains a collection of EC2 instances that are treated as a group for the purposes of automatic scaling and management.
Automatic scaling can occur via:
- Capacity Settings
- Health Check Replacements
- Scaling Policies
Capacity Settings
The size of an Auto Scaling Group is based on Min, Max, and Desired Capacity
Min is how many EC2 instances should at least be running
Max is the number of EC2 instances allowed to be running.
Desired Capacity is how many EC2 instances you ideally want to run.
ASG will always launch instances to meet minimum Capacity
Health Check Replacements
EC2 Health Check Type
ASG will perform a health check on EC2 instances to determine if there is a software or hardware issue. This is based on the EC2 Status Checks. If an instance is considered unhealthy, ASG will terminate it and launch a new instance.
ELB Health Check Type
ASG will perform a health check based on the ELB health check. ELB can perform health checks by pinging an endpoint with an expected response. If ELB determines an instance is unhealthy it forwards this information to ASG which will terminate the unhealthy instance.
ASG - Scaling Policies
Scaling out Adding More Instances
Scaling in Remove instances
Target Tracking Scaling Policy
Maintains a specific metric at a target value. e.g. If Average CPI Utilization exceeds 75% then add another server.
Simple Scaling Policy
Scales when an **alarm is breached. Not recommended, Legacy.
Scaling policies with steps
Scales when an alarm is breached, can escalate based on an alarm
ASG - ELB Integration
ASG can be associated with Elastic Load Balancers (ELB). When ASG is associated with ELB richer health checks can be settings.
Classic Load Balancers are associated directly to the assigned.
Application and Network Load Balancers are associated indirectly via their Target Groups.
Use Case
- Burst of traffic from the internet hits our domain
- Route53 points that traffic to our load Balancer
- Our load balancer passes traffic to its target group
- The target group is associated with out ASG and sends the traffic to instances registered with our ASG.
- The ASG Scaling Policy will check if our instances are near capacity
- The Scaling Policy determines we need another instance and it launches a new EC2 instance with the associated Launch Configuration to our ASG
Launch Configuration
A launch configuration is an instance configuration template that Auto Scaling group uses to launch EC2 instances.
A Launch Configuration is the same process as Launching an EC2 instance except you are saving that configuration to Launch an instance for later.
Cannot be edited