AWS Certification : High availability of EC2 instances using AutoScaling

Are you preparing for AWS Certified SysOps Administrator – Associate certification exam?  Are you ready to pass this exam? In this blog, we are writing a series of articles on topics which are covered in the AWS certified SysOps associate certification exam. You can subscribe to us for receiving further updates on this topic.

The SysOps Associate certification exam is the hardest exam in the associate level. We would recommend you pass both solution architect associated certification exam and developer associated certification exam first before of taking take this exam.

The AWS Certified SysOps Administrator – Associate exam validates technical expertise in deployment, management, and operations on the AWS platform.

The AWS SysOps Administrator – Associate Level exam validates the candidate’s ability to:

  • Deliver the stability and scalability needed by a business on AWS
  • Provision systems, services and deployment automation on AWS
  • Ensure data integrity and data security on AWS technology
  • Provide guidance on AWS best practices
  • Understand and monitor metrics on AWS
Domains covered
Domains covered at the AWS Certified SysOps associate exam

Figure #0.  Domains covered at the AWS Certified SysOps associate exam

You can download the related AWS Certified SysOps Administrator – Associate Level Exam Blueprint for more detail about it.

In this article, we are going to explain about the topic that addresses the scalability and elasticity of EC2 instances as highlighted in the AWS Blueprint from the above exam guide.

Context

Almost every day and depending of our company needs, we must maintain the availability and elasticity required into our infrastructure services, permitting that it scales up or down automatically according to some conditions that we define, contributing to improve their performance or reduce their cost.

What is Auto Scaling?

Auto Scaling is a fully managed service designed to launch or terminate Amazon EC2 instances automatically to help ensure you have the adequate number instances available for handling your application’s load.

Auto Scaling detects impaired EC2 instances and unhealthy applications, and replace the instances without your intervention, this service scales your EC2 capacity up or down according to conditions defined. This ensures that your application is getting the compute capacity that you expect, maintain performance and decrease capacity during low demand to reduce costs.

As SysOps administrator, you can reduce the need to manually provision Amazon EC2 capacity in advance if you use Auto Scaling features.

Benefits of Auto Scaling

When you use Auto Scaling, your applications gain the following benefits:

  • Better fault tolerance: Auto Scaling can detect when an instance is unhealthy, terminate it, and launch an instance to replace it. Maintain a fixed group size or adjust dynamically based on Amazon Cloud Watch
  • Better availability: Auto Scaling can help you ensure that your application always has the right amount of capacity to handle the current traffic demands. Keep your Auto Scaling group healthy and balanced.
  • Better cost management: Auto Scaling can dynamically increase and decrease capacity as needed. You just pay for the EC2 instances that you use.
  • Reusable Instance Templates: Provision instances based on a reusable template you define, called a launch configuration

Creating Auto Scaling Groups

You create collections of EC2 instances, called Auto Scaling groups, and define the limits of group size:

  • Minimum size: lower limit of number instances into the group size
  • Maximum size: higher limit of number instances into the group size
  • Desired capacity: number of instances should be running into a specific time
Auto Scaling group size limits
Auto Scaling group size limits

 Figure #1. Auto Scaling group size limits

 

To create an Auto Scaling group, you will first need to choose a template that your Auto Scaling group will use when it launches instances for you, called a launch configuration. Choose a launch configuration or create a new one, and then apply it to your group.

Step 1: Create launch configuration

First, define a template that your Auto Scaling group will use to launch instances. You can change your group’s launch configuration at any time.

Creating a Launch Configuration into an Auto Scaling Group
Creating a Launch Configuration into an Auto Scaling Group

Figure #2.  Creating a Launch Configuration into an Auto Scaling Group

Step 2: Create Auto Scaling group

Next, give your group a name and specify how many instances you want to run in it.

Creating an Auto Scaling Group
Creating an Auto Scaling Group

Figure #3.  Creating an Auto Scaling Group

Your group will maintain this number of instances and replace any that become unhealthy or impaired.
You can also use Amazon CloudWatch to send alarms to trigger scaling activities and Elastic Load Balancing (ELB) to distribute traffic to your instances within Auto Scaling groups. If you have predictable load changes, you can set a schedule through Auto Scaling to plan your scaling activities, avoid create schedules that make conflict.

Creating a Scheduled Action for Auto Scaling Group
Creating a Scheduled Action for Auto Scaling Group

Figure #4.  Creating a Scheduled Action for Auto Scaling Group

Auto Scaling enables you to take advantage of the safety and reliability of geographic redundancy by spanning Auto Scaling groups across multiple Availability Zones within a region. When one Availability Zone becomes unhealthy or unavailable, Auto Scaling launches new instances in an unaffected Availability Zone.

Balancing resources across Availability Zones is a best practice for well-architected applications, as this greatly increases aggregate system availability. Auto Scaling automatically balances EC2 instances across zones when you configure multiple zones in your Auto Scaling group settings.

Auto Scaling Group Lifecycle

 The lifecycle starts when the Auto Scaling group launches an instance and puts it into service. The lifecycle ends when you terminate the instance, or the Auto Scaling group takes the instance out of service and terminates it.

The complete lifecycle of instances in an Auto Scaling group
The complete lifecycle of instances in an Auto Scaling group

Figure #5.  The complete lifecycle of instances in an Auto Scaling group

You can add a lifecycle hook to your Auto Scaling group so that you can perform custom actions when instances launch or terminate. Adding lifecycle hooks to your Auto Scaling group gives you greater control over how instances launch and terminate. For example, you could install or configure software on newly launched instances, or download log files from an instance before it terminates.

Detecting “Unhealthy” instances

An unhealthy instance is one where the hardware has become impaired for some reason (bad disk, etc.), or it is not passing a user-configured ELB health check. Auto Scaling performs health checks on each individual EC2 instance at regular intervals, and if the instance is connected to an Elastic Load Balancing load balancer, it can also perform ELB health checks.

An Unhealthy instance into the Auto Scaling Group
An Unhealthy instance into the Auto Scaling Group

Figure #6.  An Unhealthy instance into the Auto Scaling Group

Auto Scaling might suspend processes for Auto Scaling groups that repeatedly fail to launch instances. This is known as an administrative suspension, and most commonly applies to Auto Scaling groups that have been trying to launch instances for over 24 hours but have not succeeded in launching any instances.

Distributing traffic between EC2 instances

To use a load balancer with your Auto Scaling group, create the load balancer and then attach it to the group.

If you are preparing for the AWS associate certifications exam and looking for any help, please send us a mail to call our customer support team. And Benchmark your AWS knowledge with one or more of the highly demanded AWS Foundation certifications.

Important Points to Remember for the AWS Certified SysOps Administrator – Associate Certification exam

  • Auto Scaling is a web service designed to launch or terminate Amazon EC2 instances automatically based on user-defined policies, schedules, and health checks
  • Some benefits for using Auto Scaling: Automated provisioning, adjustable capacity, and reusable instance templates.
  • There are no additional fees with Auto Scaling
  • You could enable CloudWatch detailed monitoring when creating a launch configuration
  • Auto Scaling performs health checks per EC2 instance at regular intervals or by an ELB health check configured
  • You should span your Auto Scaling groups across multiple Availability Zones within a region to obtain more safety and reliability, it’s a best practice
  • The Auto Scaling group has a lifecycle and you can add Auto Scaling lifecycle hooks to perform custom actions
  • You can set a schedule through Auto Scaling to plan your scaling activities, please avoid schedules that make conflict

Glossary

Term Brief description
Auto Scaling group An 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 
Launch configuration A launch configuration is a template that an Auto Scaling group uses to launch EC2 instances. When you create a launch configuration, you specify information for the instances such as the ID of the Amazon Machine Image (AMI), the instance type, a key pair, one or more security groups, and a block device mapping. 
Scaling plans scaling plan tells Auto Scaling when and how to scale. For example, you can base a scaling plan on the occurrence of specified conditions (dynamic scaling) or on a schedule. 
Fleet management Fleet management refers to the functionality that automatically replaces unhealthy instances and maintains your fleet at the desired capacity 
Dynamic scaling The dynamic scaling capabilities of Auto Scaling refers to the functionality that automatically increases or decreases capacity based on load or other metrics 
Scaling policy A scaling policy is a set of instructions for making such adjustments in response to an Amazon CloudWatch alarm that you assign to it. In each policy, you can choose to add or remove a specific number of instances or a percentage of the existing group size, or you can set the group to an exact size 
Desired capacity The number of EC2 instances that the group should have at any time, also called desired capacity

 

Summary

In this article, we have explained about how to maintain the availability and elasticity of EC2 instances using Auto Scaling service, the auto scaling lifecycle and distributing traffic between instances using load balancing.

References:

[1] Auto Scaling Faqs, https://aws.amazon.com/autoscaling/faqs/
[2] Amazon Auto Scaling Documentation,
https://aws.amazon.com/documentation/autoscaling/
[3] AWS Certified SysOps Administrator – Associate Certification.
https://aws.amazon.com/certification/certified-sysops-admin-associate/

About Pavan Gumaste

Pavan Rao is a programmer / Developer by Profession and Cloud Computing Professional by choice with in-depth knowledge in AWS, Azure, Google Cloud Platform. He helps the organisation figure out what to build, ensure successful delivery, and incorporate user learning to improve the strategy and product further.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top