About Autoscaling
1) Helps you to handle that you have correct number of amazon EC2 instances.
1) Helps you to handle that you have correct number of amazon EC2 instances.
2) Desired Capacity – Ensures group has that many instances
3) Helps to maintain number of instances
4) Can mention minimum and maximum size to maintain
Components
1) Auto Scaling group
2) Launch
Configuration – Template used by auto scaling group.
3) Scaling
policy
Auto Scaling group
Contains a collection of EC2 instances that share similar characteristics and are treated as a logical grouping for the purposes of instance scaling and management.
Contains a collection of EC2 instances that share similar characteristics and are treated as a logical grouping for the purposes of instance scaling and management.
When you create a Auto Scaling group you must specify a
launch configuration. You can specify your launch configuration with multiple
auto scaling group’s
Example - If an application operates across multiple
instances, you might want to increase the number of instances in that group to
improve the performance of the application, or decrease the number of instances
to reduce costs when demand is low. You can use the
Auto Scaling group to scale the number of instances automatically based on criteria that you specify, or maintain a fixed number of instances even if a instance becomes unhealthy. This automatic scaling and maintaining the number of instances in an Auto Scaling group is the core functionality of the Auto Scaling service.
An Auto Scaling group starts by launching enough EC2
instances to meet its desired capacity.
The Auto Scaling group maintains this number of instances
by performing periodic health checks on the instances in the group. If an
instance becomes unhealthy, the group terminates the unhealthy instance and
launches another instance to replace it
Imp : An auto scaling group can have only one Launch
configuration
We can create an Auto scaling group directly from a EC2 instance. When you use this feature Auto scaling automatically creates a Launch configuration for you as well.
We can create an Auto scaling group directly from a EC2 instance. When you use this feature Auto scaling automatically creates a Launch configuration for you as well.
Launch Configuration – Template that an auto scaling
group uses to launch EC2 instances. Information specified AMI, Instance Key
Pair, Security Groups and Block device mapping
Launch configuration can’t be modified after creation. To
change we need to create new launch configuration and update your auto scaling
group.
New Launch configuration will be used by new instances,
existing instances wont be affected
Creation Launch configuration - Can be created by any one of below methods
1) Using an EC2 instance
2) From an instance and override the block devices
3) Create a Launch configuration and override the instance type
Auto Scaling Cooldown
Auto scaling cool down period is a configurable
setting for your ASG that helps to ensure that auto scaling doesn’t launch or
terminate additional instances before the previous scaling activity takes
effect.
When you manually scale your auto scaling period the default is not
to wait for the cooldown period. But you can can override the default and honor the period
If an instance becomes unhealthy, auto scaling does not
wait for the cool down period to complete before replacing the healthy
instance.
Scaling Plans
Auto Scaling provides several ways to
scale your Auto Scaling group. Below are some of the scaling plans
Maintain
current instance levels at all times
Manual scaling Scale based on a schedule
cale based on demand
Multiple Scaling Policies - An Auto Scaling group can have more than one scaling policy attached to it any given time. In fact, we recommend that each Auto Scaling group has at least two policies: one to scale your architecture out and another to scale your architecture in.
Accessing Methods – CLI, Power shell
Benefits - Better
fault tolerance, Availablity and Cost Management.
Life Cycle – Life Cycle starts when the Auto scaling group launches and instance and puts it into service. Lifecycle ends terminates when you terminate the instance
Charging - No Charges for Auto Scaling, charges are only for resources
Note : You are billed for instances as soon as they are
launched including the time that they are not in service
Termination policy
1) Check is Instances are in Multi AZ. If so, it selects the AZ with most instance. If more than one AZ with this configuratiion then it selects the instances that use the oldest launch configuration
2) If multiple instances uses old launch configuration. Choose the one which is near to next billing hour.
3) If more instances are close to next biling hour. then it selects one at random.
Customizing the termination policy
For customized termination policy, auto scaling first checks the AZ for any imbalance. If an AZ has more instances than the other AZ used by the group. Then Auto Scaling applies your termination policy on the instances of the imbalanced AZ. If the zones are balanced then Auto Scaling applies the termination policy you specified.
Currently supports following custom
Oldest instance
Newest instance
Oldest launch configuration
Close to Next instance Hour
Default
Scale out - Fully Configured and EC2 health check passed instance is attached to auto scaling and it enters In Service state. It is counted against the desired capacity
Instance In Service - Instance remains in service until one of the following occurs
Scale in
You bu in Standby state
You detach the instance
Instance fails health Check
Scale in - Uses termination policy to terminate. It is important to create scale in for each scale out
Newest instance
Oldest launch configuration
Close to Next instance Hour
Default
Scale out - Fully Configured and EC2 health check passed instance is attached to auto scaling and it enters In Service state. It is counted against the desired capacity
Instance In Service - Instance remains in service until one of the following occurs
Scale in
You bu in Standby state
You detach the instance
Instance fails health Check
Scale in - Uses termination policy to terminate. It is important to create scale in for each scale out
1) Instance in running state
2) AMI used to launch must still exist
3) Instance not member of other Auto Scaling group
4) If auto scaling has load balancer, instance LB must be in the classic or same VPC.
If the auto scaling has an attached target group, the instance and the application LB must be in same VPC
If the auto scaling has an attached target group, the instance and the application LB must be in same VPC
Life Cycle Hook - Enables you to perform custom action when auto scaling launches or terminates instances. Eg: - You Could install or Configure software on newly launched instances or download log files from instance before it terminates. Auto
Scaling puts the Instance into a wait state (
Pending:Wait or Terminating:Wait). The
instance remains in this state until either you tell Auto Scaling to continue
or the timeout period ends.
No comments:
Post a Comment