What Is AWS Application Load Balancer – AWS ALB
Your incoming traffic is automatically split among numerous targets, including EC2 instances, containers, and IP addresses in one or more Availability Zones, thanks to elastic load balancing. It keeps track of the wellbeing of the registered targets, only sending traffic to those that are in good shape. In this we will setup this Application Load Balancer – AWS ALB on two EC2 instances, running in the same region.
Network Load Balancer
The transport layer (TCP/SSL) routing decisions are made by a network load balancer. Millions of queries can be handled per second. Using a flow hash routing technique, the load balancer chooses a target from the target group for the default rule after receiving a connection. On the port given in the listener configuration, it tries to establish a TCP connection to the chosen target. Without changing the headers, it transmits the request. Dynamic host port mapping is supported by network load balancers. However, in this blog we will continue with Application Load Balancer.
Why AWS Load Balancing ?
Customers have a better experience thanks to load balancers’ reduction of the increased server load and maintenance of responsiveness and smooth operations.
Try this: How To Create Animated Videos In An Android Phone
It also equally distributes the load among various servers attached to it, so the traffic coming from the internet or internal can be managed easily by distributing it to the server which is empty.
Before Creating AWS ALB (AWS load balancer) we will need two or more EC2 Instances or Containers. In this post we will be demonstrating only with EC2 Instances.
Let’s get started by setting up two EC2 instances. I will show you how to setup the first one, same will be the way with second EC2 instance. Go to EC2 Dashboard -> EC2 instances -> Launch Instances
First EC2 Instance
Give EC2 instance a name, I will give my first instance name of “A(instance)“
Now select the type of AMI(Amazon Machine Image) you want for the instance, I am setting up it as Amazon Linux Instance
Just in Case:An instance can be launched using an Amazon Machine Image (AMI), which is a supported and updated image offered by AWS. When you launch an instance, you must specify an AMI. When you need numerous instances with the same configuration, you can launch them all from a single AMI. When you need instances with specific specifications, you can launch them using different AMIs.
Now it will ask for key pair login, you can choose to create a key pair, but I will proceed without key pair, since no need to login to the EC2 instance in this case.
You might like: How To Capture 360 Degree Pictures In Android Phone
Now create security group and Check the Allow HTTPs and HTTP from the internet options.
Now scroll down and expand Advanced Details
Now scroll down to the end and in the User data add the following script.
#!/bin/bash sudo yum update -y sudo yum install -y httpd sudo systemctl start httpd.service sudo systemctl enable httpd.service sudo echo "<h1> 🌋 At $(hostname -f) Instance A 🌋 </h1>" > /var/www/html/index.html
Now click on Launch Instance
NOTE: In case you forgot to select the keypair option ,it will again ask you to choose one, just like this
After launch instance, instance will be launched successfully showing this dialog box
Now, if we go to the public IP address of this instance the page will open like this.
Also Read: How Easy Is Register Your Business On Google in 2022
Second EC2 Instance
Do the same steps to setup another EC2 instance just change the User Data of instance to this
#!/bin/bash sudo yum update -y sudo yum install -y httpd sudo systemctl start httpd.service sudo systemctl enable httpd.service sudo echo "<h1> 🏝️ At $(hostname -f) Instance B 🏝️ </h1>" > /var/www/html/index.html
Go to the public IP address of this instance, and you will see the page like this
Configuring An Application Load Balancer – AWS ALB Load Balancer
After setting up the EC2 instances now we can proceed with AWS ALB
Now let’s setup the AWS Load Balancer for these instances
You might also like this: How to send messages using WhatsApp Cloud API
Search for Load Balancers in the console and click on Load Balancers EC2 feature
Now click on Create Load Balancer
Now under Application Load Balancer( AWS ALB), choose Create
Also Read: How to Turn A PDF Into An Audiobook Easily
Enter a name for the Load Balancer( AWS ALB), I am going in with the name A-B-load-balancer just for the sake of demonstration.
Now select two or more availability zones
Proceed with default security group
Listener is the port at which the load balancer will listen to the server running, since both my instances are running on port 80, I will make my load balancer listener to listen on port 80 (default). And click on create Target Group, this will open in new window.
You might like this: How to Turn A PDF Into An Audiobook Easily
Now choose Target type as Instances, as I want my instances to be mapped to my load balancer.
Give the target group a name.
Now, in this option you need to select that how the load balancer will come to know that the EC2 instances mapped to it are working fine. To do this added the health check to be performed at /index.html in both the EC2 instances. Now click Next.
Register both the EC2 instances by selecting them and Click on include as pending below.
Try this: Best Way Send Confidential Emails In 2022
Now click on Create Target Group.
This will bring you back to the screen where we were creating our load balancer, Now click on refresh button and it will show the target group we created and select that target group .
Also Read: How To Secure A PDF File.
Now click on Create Load Balancer
After successful creation it will show the notification like this.
Now if you go to the DNS of the Load Balancer (AWS ALB),
it will now split load equally between both the EC2 instances, you can check this by refreshing the page continuously and it will work as shown below.
Try this: How To Run Windows On Web Browser
Hurray ! We have successfully implemented our Application Load Balancer ( AWS ALB ) on our two EC2 instances.
Also try: How To Capture 3D Images In Android And IPhone
application load balancer components
In this way we can implement Application Load Balancer( AWS ALB) on our servers running in different EC2 instances, in order to manage the traffic among them equally.