Home Linux & Systems Cybersecurity Cloud & DevOps Networks & Infrastructure SIEM & Monitoring DFIR & Threat Intel Development & Other All categories Projects About Tools

Creating an Application Load Balancer with Auto Scaling on AWS

Leer en espanol
Creating an Application Load Balancer with Auto Scaling on AWS

Table of contents

Through this configuration we can horizontally scale the application servers and thus increase the ===

In this example we are going to show how to implement a load balancer using AWS.

Through this configuration we will be able to horizontally scale the application servers and thus increase performance, reduce latency and provide tolerance to failure.

Previously we saw how to set up a load balancer which had two public subnets and a balancer.  This time we are going to complicate things a little more and we will have four subnets, a balancer and two nat gateways.

Network diagram:

Diagrama de red 1 1

Network settings:

VPC
Name tag: RedOrbita VPC
IPv4 CIDR block: 10.200.0.0/20
Subnet
Name tag: Public Subnet 1
IPv4 CIDR block: 10.200.0.0/24
Name tag: Public Subnet 2
IPv4 CIDR block: 10.200.1.0/24
Name tag: Public Private 1
IPv4 CIDR block: 10.200.10.0/24
Name tag: Public Private 2
IPv4 CIDR block: 10.200.11.0/24
Route Table
Destination: 0.0.0.0/0
Target: Internet Gateway

We begin with the deployment of the infrastructure

We create the VPC:

To deploy a new server we have to go to Service > VPC > Your VPCs > Create VPC

Selección 001

We create the two public subnets:  Services > VPC > Subnets > Create Subnet

AWS LOADBALANCER00001

We generate the Internet Gatewa: Services > VPC > Internet Gateway > Create Internet Gateway

LoadBalancer0003

We attach the Internet Gateway to the VPC. We select the Internet Gateway created > Actions > Attach VPC

LoadBalancer0004

We select the VPC created previously.

LoadBalancer0005

We configure the Security Group with the corresponding permissions: Service > VPC > Security Group > Create Security Group and once created at the bottom we create the corresponding rules

LoadBalancer0006

We create the route table: Service > VPC > Route Tables > Create Route Tables. once created we will Routes and we configure the necessary routes:

LoadBalancer0010

We create the ROLE: Service > IAM > Role > Create Role > We select EC2 LoadBalancer0007

Following

LoadBalancer0008  LoadBalancer0009

Next we create two Nat Gateways: Service > VPC > Nat Gateway > Create Nat Gateway

AWS LOADBALANCER00002

We generate two instances in different areas, in order not to lengthen this tutorial I am not going to show how to deploy an instance, for this you can see it in the following link:

Deploy a virtual machine in AWS

Once the two instances have been generated in the different subnets we are going to create the load balancer, to do this we are going to:

Services > EC2 > Load Balancers > Create Load Balancer

LoadBalancer0011

We select the option Application Load balancer (In the case that we want to perform a layer 7 balancing)

LoadBalancer0012

We assign a name, protocol by which load balancing will be carried out (in my case only on port 80) and we select the two private subnets created previously

LoadBalancer0013

AWS LOADBALANCER00003

Following…

LoadBalancer0015

We configure the Security Group

LoadBalancer0016

Here we can configure the load balancing status check, in my case I leave it by default.

LoadBalancer0017

We select the instances and click: Add to registered

AWS LOADBALANCER00004

It shows us a brief summary of the configuration made. Create!

LoadBalancer0019

Once the balancer is created, we copy the DNS name of the balancer and access the same URL several times. If everything went correctly it should balance the different instances.

LoadBalancer0020

Before configuring auto-escalation, we create the AMI from which it will be fed.

Create AMI in AWS

Once the AMI has been created and we have verified that the balancer is working correctly, we proceed to configure the auto-lock: Service > EC2 > AUTO SCALING > Launch Configurations >Create Auto Scaling

AWS LOADBALANCER00005

The configuration wizard opens, Next.

AWS LOADBALANCER00006

We select the ME created previously.

AWS LOADBALANCER00007

We proceed to configure the instance

AWS LOADBALANCER00008

AWS LOADBALANCER00009

AWS LOADBALANCER00010

AWS LOADBALANCER00011

AWS LOADBALANCER00012

AWS LOADBALANCER00013

The auto-scaling configuration wizard begins. In it we must select our VPC and the Private subnets.

AWS LOADBALANCER00014

In Advanced Details we select the check of Load Balancing

AWS LOADBALANCER00015

We create alarms to increase or decrease the number of instances depending on the load.

AWS LOADBALANCER00016

AWS LOADBALANCER00017

AWS LOADBALANCER00018

We create the alarm so that it reduces the type of instances in the case

AWS LOADBALANCER00019

The two configured alarms would look like this:

AWS LOADBALANCER00020

We create the notification

AWS LOADBALANCER00021

We configure the tag

AWS LOADBALANCER00022

It shows us a brief summary

AWS LOADBALANCER00023

If we now go to Instances we can see how it begins to deploy instances:

AWS LOADBALANCER00024

We would only need to perform a stress test to see if the alarms we have configured are working correctly.

:wq!

Comments