AWS Autoscaling
- Autoscaling ensures application is able to handle load by increasing the number of ec2 instances when needed and decreasing the number of ec2 instances in the case of decreased load
- Autoscaling is used to ensure the desired number of ec2 instances are always running.
- Autoscaling Terms
- Minimum Size
- Desired capacity
- Maximum Size

- Desired Capacity can be set to static number in such cases aws will ensure you will always have fixed set of ec2 instance running your application
- To make Desired Capacity Dynamic, We can specify any cloud watch metric such as cpu, network io, memory load etc to determine the desired capacity
- In the case of web servers & app servers as users increase or as load increases the stress will be more on CPU, so we will be using CPU metrics to determine the desired capacity
- Auto Scaling Components
- Auto Scaling Groups:
- We specify minimum, maximum & desired capacity
- Configuration Templates:
- We can use Launch templates or Launch configurations to determine the ami and other ec2 instance details
- Scaling Options:
- Dynamic
- Fixed number
- Manual Scaling
- Auto Scaling Groups:
Launch Configuration (LC)
- LC is an instance configuration template that ASG uses to launch ec2 instance.
- Lets observe the different configuration details specified in creating a launch configuration
- AMI-id
- instance type
- Additional Configuration
- Spot instance requests
- IAM Role
- Monitoring
- EBS optimized instance
- User-Data
- Volume
- Security Groups
- Key Pair
Launch Templates
- This is similar to Launch configuration. Launch template allows us to have multiple versions of the template.
- Launch template also gives option for dynamic values while creating
- Using Launch Template you can specify the same configuration as launch template, some of the values can be made dynamic and versioing is enabled.
Auto Scaling Groups (ASG)
- ASG contains collection of EC2 instances for the purpose of automatic scaling & management.
- ASG Group has features such as
- Health check replacements
- Scaling policies
- Size of ASG depends on number of instances in Desired Capacity which can be adjusted on demand, manually or by using automatic scaling
Scaling Options
- AWS EC2 Autoscaling provides the following scaling options
- Maintains current instance levels at all times:
- We configure ASG to maintain the specified number of running instance all the time.
- Scale manually
- Scale on a schedule:
- Also referred as scheduled scaling.

- Also referred as scheduled scaling.
- Scale based on demand:
- If your application needs a dynamic scaling policy

- Scaling policy type:
- Simple Scaling:
- Increase or decrease the current capacity of the group based on single scaling adjustment
- Step Scaling:
- Increase or decrease the current capacity of the group based on set of scaling adjustement
- Target tracking Scaling:
- Increase or decrease the current capacity of group based on target value for a specific metric
- Simple Scaling:
- Now configure Target tracking scaling and login into ec2 instance and run the stress (create artifical load on ec2 instances)

- Now observe the autoscaling group for 10 mins and you should see the ec2 instances automatically added as cpu utilization moves beyond the configured number
- If your application needs a dynamic scaling policy
- Maintains current instance levels at all times:
- Exercise: Create an autoscaling group with launch template for running ec2 instances with
- AMI: game of life
- minimum size: 1
- maximum size: 3
- desired capacity: 1
- Set Target tracking scaling policy to set at Average CPU utilization of 50%
Next Steps:
- Implementing a Loadbalancer
- Layer 4
- Layer 7
- Add a Route 53 route from DNS to gameoflife.
