AutoScaling && Load balancers in AWS

·

3 min read

AutoScaling && Load balancers in AWS

Let's understand first :

What is autoscalling?

Auto Scaling monitors your applications and automatically adjusts capacity to maintain steady, predictable performance at the lowest possible cost.

What are load balancers?

Lb is used to distribute traffic between our servers to maintain availability and scalability.

There are three lbs: 1. Application LB 2. Network LB 3. Gateway Lb

for more reference check the below pics details.

Steps :

We will be launching two servers where we will be installing nginx and will check lb.

EC2 > launch instance > ubuntu > server 1 
install nginx using sudo apt install nginx
make sure you should open port 80 as nginx works on port 80 by default

EC2 > launch instance > ubuntu > server 2 
install nginx using sudo apt install nginx 
make sure you should open port 80 as nginx works on port 80 by default

Here are the details :

server 1 :

server 2 :

let's create LB for these two servers:
EC2 Dashboard > Load balancers > choose Application LB

fill details > choose vpc if you have any, here am using default vpc > choose AZ of your servers

Before this you need a security group && a target group

here i have created a security group ALB security group :

Next, go to ec2 > target group for instances create one and attach servers to it.

Here i have created target group with default vpc and attanched instances :

Now ec2 > launch template fill details attach target group and security group create load balancer and wait for LB to active.

Remember one thing is that whenever you will LB it will provide you a DNS.

Let's take that DNS mentioned in the pic and paste it to the browser.

in my case DNS name is : MYALB-110058523.us-east-1.elb.amazonaws.com

successfully loading my server 1 and if you refer you will get server 2.

successfully balanced between servers.

Autoscaling :

Before that let's create an image for one of the servers that needs to be auto-scaled when the traffic loads are high.

EC2> Seelect one of the servers>

EC2 > Auto scaling group > create > give name and choose existing launch template

Choose vpc and az based on your servers :

then click next > choose to an existing LB >add target group > fill details

and then on the next page customize your checks like desired capacity, minimum capacity > next > create

Here is my ASG :

Now if you go to activity you will see the instance launching :

Even if you need one of the servers it will auto-create and scale as per our requirement.

You can see the - name server ASG created server.

That's how you can configure ASG && LB.