Start a Project

Set up Amazon Auto Scaling

In our previous blog, we got an overview of AWS auto-scaling, its features, and its applicability.

In this blog, we will begin with setting up an Auto Scaling Group and integrating it with AWS Elastic Load Balancer and AWS CloudWatch.

Let’s Start With Auto Scaling Launch Configuration

First and foremost, we will create a launch configuration that acts as a template that the auto-scaling group uses to launch EC2 instances.

It contains information about AMI ID, instance type, one or more security groups, subnet(s), key pair, user data, etc.

Step 1- login into your AWS account, and go to Launch Configurations under Auto Scaling Category.

Then click on ‘Create Autoscaling Group’

Step 2 – First, we need to create a launch configuration, so click on “Create launch configuration”.

Then, it will ask you to select an AMI for launch configuration. We are using my custom AMI named DND – ami-09e3a91f which has LAMP server and other dependencies already installed.

Here, we will select the t2.micro instance that comes under AWS free-tier criteria. Moving further to configure details,

Here, we have named our launch configuration “new-launch-configuration”. As shown above, we are taking all the other values as default.

Although we have mentioned a simple bash script in user data. User data contains a set of commands that we want to get executed on the instances launched by the auto-scaling group.

At this point, we are just entering a digit in a file as an example. Now, moving on to adding storage.

Step 3 – Taking all values as defaults, we will move on to configure the security group.

We will here select an existing security group that is listening to our ports or we can create a new security group and set up an access control list in it.

Review launch configuration details. AWS will launch instances based on this template. After reviewing, click on “Create launch configuration”.

Here, we are choosing an existing key pair. We can also create a new key pair. Clicking on Create launch configuration,

After a while, the launch configuration will be created and we can review all the details. Now we have to create an Auto-scaling group.

Getting Started with Auto Scaling Group

Step 1 –  We have named our auto-scaling group “new-autoscaling-group”.

Group size is set to 1 which defines the number of instances that get launched after the group creation.

Also, we have selected our default VPC and all subnets within that region. On further scrolling down, configure advanced details as:

We have checked on the option for receiving traffic from the load balancer and also selected our already created classic load balancer naming “test”.

Step 2 – We will take rest of the values as default and move on to configure scaling policies.

As the auto-scaling group automatically scales instances up and down, depending upon the policies created, we will choose scaling policies to adjust the capacity of this group.

Policies can be created with the help of Amazon CloudWatch. Here, we have already created an alarm for scale-out policy depending upon CPU usage.

Now, moving on to create scale in policy:

As we can see, we have already created an alarm for scale-in policy based on CPU usage. Moving on to the next step,

Step 3- Here  we will configure no notification policies and move to a further step,

Add a tag to our group and click on review.

Review all the details and click on Create Auto Scaling group.

Now, our auto-scaling group has been created which receives traffic from the load balancer named “test” and, has desired number of instances as 1 and minimum to maximum instance counts as 1 to 2.

No running instance is associated with our load balancer in this auto-scaling group, so a new instance will launch using the launch configuration to meet the minimum instance count.

After passing through load balancer health checks, a new instance will be created under this group.

As we can see, an instance is InService within one of the availability zones of our region using our custom launch configuration.

Although we have already created our scaling policies, we can add more alarms based on these policies by clicking on “the Scaling Policies” option. Click on add policy and create a new alarm as:

This is the same alarm that we have created for monitoring CPU usage for scale-out policies.

Conclusion

Our AWS Auto Scaling Group is all set up with integration with AWS Classic Load Balancer and  AWS CloudWatch.

We can create more scaling policies for auto-scaling groups to ensure high availability and reduce server downtime.

So far we have discussed creating an Amazon auto-scaling group. In our next blog, we will discuss a complete architecture using AWS resources.

Need Support?

Thank You for reading this Blog!

For further more interesting blogs, keep in touch with us. If you need any kind of support, simply raise a ticket at https://webkul.uvdesk.com/en/.

For further help or queries, please contact us or raise a ticket.

Exit mobile version