1.4-Amazon EC2 Auto Scaling - Digital Cloud Training
1.4-Amazon EC2 Auto Scaling - Digital Cloud Training
1.4-Amazon EC2 Auto Scaling - Digital Cloud Training
PLEASE READ: This page is copied from the AWS Certified Solutions
Architect Associate training notes. Please note that for the Developer
Associate exam you don’t need to know everything on this page but an
understanding of Auto Scaling is expected so it’s recommended to be
familiar with these concepts to be prepared for any questions that may
appear on your exam.
This page is specifically for Amazon EC2 Auto Scaling – Auto Scaling will also
be discussed for the other services on their respective pages.
Availability, cost, and system metrics can all factor into scaling.
Auto Scaling can span multiple AZs within the same AWS region.
Auto Scaling can be configured from the Console, CLI, SDKs and APIs.
There is no additional cost for Auto Scaling, you just pay for the resources
(EC2 instances) provisioned.
You can determine which subnets Auto Scaling will launch new instances into.
Auto Scaling will try to distribute EC2 instances evenly across AZs.
Launch configuration is the template used to create new EC2 instances and
includes parameters such as instance family, instance type, AMI, key pair and
security groups.
A launch configuration:
If you want to change your launch configurations you have to create a new
one, make the required changes, and use that with your auto scaling
groups.
You can use a launch configuration with multiple Auto Scaling Groups (ASG).
You can attach one or more classic ELBs to your existing ASG.
You can attach one or more Target Groups to your ASG to include instances
behind an ALB.
Once you do this any EC2 instance existing or added by the ASG will be
automatically registered with the ASG defined ELBs.
You can add a running instance to an ASG if the following conditions are met:
Scaling
The scaling options define the triggers and when instances should be
provisioned/de-provisioned.
The following table describes the scaling options available and when to use
them:
The scaling options are configured through Scaling Policies which determine
when, if, and how the ASG scales and shrinks.
The following table describes the scaling policy types available for dynamic
scaling policies and when to use them (more detail further down the page):
The diagram below depicts an Auto Scaling group with a Scaling policy set to
a minimum size of 1 instance, a desired capacity of 2 instances, and a
maximum size of 4 instances:
Then use a target tracking policy that configures your Auto Scaling group to
scale based on the custom metric and a set target value. CloudWatch alarms
invoke the scaling policy.
Use a custom “backlog per instance” metric to track not just the number of
messages in the queue but the number available for retrieval.
You can define Instance Protection which stops Auto Scaling from scaling in
and terminating the instances.
If Auto Scaling fails to launch instances in an AZ it will try other AZs until
successful.
Scale-out is the process in which EC2 instances are launched by the scaling
policy.
Scale-in is the process in which EC2 instances are terminated by the scaling
policy.
Health checks:
If using an ELB it is best to enable ELB health checks as otherwise EC2 status
checks may show an instance as being healthy that the ELB has determined
is unhealthy. In this case the instance will be removed from service by the
ELB but will not be terminated by Auto Scaling.
Elastic IPs and EBS volumes are detached from terminated instances and will
need to be manually reattached.
Using custom health checks a CLI command can be issued to set the
instance’s status to unhealthy, e.g.:
Once in a terminating state an EC2 instance cannot be put back into service
again.
However there is a short time period in which a CLI command can be run to
change an instance to healthy.
You can manually remove (detach) instances from an ASG using the AWS
Console or CLI.
When detaching an instance you can optionally decrement the ASG’s desired
capacity (so it doesn’t launch another instance).
You can suspend and then resume one or more of the scaling processes for
your Auto Scaling group.
You can manually move an instance from an ASG and put it in the standby
state.
Instances in standby state are still managed by Auto Scaling, are charged as
normal, and do not count towards available EC2 instance for
workload/application use.
Auto scaling does not perform health checks on instances in the standby
state.
You can choose to use Spot instances in launch configurations and specify a
bid price.
If you want to change the bid price you need to create a new launch
configuration.
An instance is launched.
An instance is terminated.
An instance fails to launch.
An instance fails to terminate.
Merging ASGs.
You can merge multiple single AZ Auto Scaling Groups into a single multi-
AZ ASG.
Merging can only be performed by using the CLI.
Process is to rezone one of the groups to cover/span the other AZs for the
other ASGs.
Then delete the other ASGs.
Can be performed on ASGs with or without ELBs attached to them.
The resulting ASG must be one of the pre-existing ASGs.
Cooldown Period:
The cooldown period is a configurable setting for your Auto Scaling group
that helps to ensure that it doesn’t launch or terminate additional
instances before the previous scaling activity takes effect.
The default cooldown period is applied when you create your Auto Scaling
group.
The default value is 300 seconds.
You can configure the default cooldown period when you create the Auto
Scaling group, using the AWS Management Console, the create-auto-
scaling-group command (AWS CLI), or the CreateAutoScalingGroup API
operation.
Automatically applies to dynamic scaling and optionally to manual scaling
but not supported for scheduled scaling.
Can override the default cooldown via scaling-specific cooldown.
The warm-up period is the period of time in which a newly created EC2
instance launched by ASG using step scaling is not considered toward the
ASG metrics.
Monitoring
Basic monitoring sends EC2 metrics to CloudWatch about ASG instances
every 5 minutes.
When the launch configuration is created from the console basic monitoring
of EC2 instances is enabled by default.
When the launch configuration is created from the CLI detailed monitoring of
EC2 instances is enabled by default.
When you enable Auto Scaling group metrics, Auto Scaling sends sampled
data to CloudWatch every minute.
Configure ASG and EC2 monitoring options so they use the same time period,
e.g. detailed monitoring (EC2) and 60 seconds (ASG), or basic monitoring
(EC2) and 300 seconds (ASG).
Limits
References
https://docs.aws.amazon.com/autoscaling/ec2/userguide/what-is-
amazon-ec2-auto-scaling.html
https://aws.amazon.com/ec2/autoscaling/faqs/
https://aws.amazon.com/ec2/autoscaling/pricing/
Connect Follow
About us Facebook
Contact us Youtube
Submit Feedback Twitter