General
- Adds or remove EC2 instances according to the load.
- Has minimum, maximum and desired number of instances.
- Can automatically register instances to ELB target group
- Used launch template or launch configuration to determine the instance type, volume, network (VPC & Subnet), security group, key pair of the instance to be launched.
- Scale-in = remove instances, Scale out = add instances
- To update ASG you need to provide new launch template or launch configuration.
- Terminates instances marked as unhealthy by ELB
- Cool Down Period – No instances will be launched or terminated. Default to 300 seconds.
- Has Lifecycle Hooks – Additional action can be performed before an instances is in service or terminated.
- Health Checks:
- EC2
- ELB
Types of Scaling
- Manual
- By manually changing the minimum, maximum or desired capacity
- Dynamic (Scale based on metric)
- Targeted
- Scale-in when certain metric is above threshold, scale-out when below threshold.
- example, when Average CPU Utilization is above a limit then increase instance.
- Does not need to create a CloudWatch Alarm but can use CloudWatch Metrics
- Can use predefined or customized metrics.
- Simple
- Required the use of CloudWatch Alarm
- Based on CloudWatch Alarm can add/remove/set require instances.
- Can specify the high / low of the alarm
- Required instances can be a percentage of the group
- Step
- Required the use of CloudWatch Alarm
- Similar to Simple but can have step adjustment e.g.
- CPU > 30% add 1 instance
- CPU > 50% add 2 instances
- Targeted
- Scheduled (Scale based on schedule)
- Used when demand is known for a particular period in time.
- Predictive
- Use machine learning to predict capacity requirement.
- Good for:
- Cyclical traffic, such as high use of resources during regular business hours and low use of resources during evenings and weekends
- Recurring on-and-off workload patterns, such as batch processing, testing, or periodic data analysis
- Applications that take a long time to initialize, causing a noticeable latency impact on application performance during scale-out events
Default Termination Policy
- Determines the AZ with the most instances
- Determine which instances is launched from the oldest launch template/configuration
- Determine closest to the billing hour
- Terminate in random.