How to create an Application Load Balancer on AWS

Load Balancer falls under the EC2 services of AWS. An Application Load Balancer works at the seventh layer of the Open Systems Interconnection (OSI) model, the application layer. We can add and remove targets from our load balancer as per our needs without affecting the flow of requests to the application. Application Load Balancer supports for path-based routing: forward requests based on the URL in the request, host-based routing: forward requests based on the host field in the HTTP header, routing based on fields in the request, registering targets by IP address: targets outside the VPC for the load balancer can also be added. These are a few of the benefits of using the Application Load Balancer.

For more information about the Application Load Balancer click here.

With Application Load Balancer we only pay for what we use. Click here to know more about its pricing.

In this article, we will see how to create an Application Load Balancer, register instances, and access the Load Balancer using its DNS.

Pre-requisites

  1. AWS Account (Create if you don’t have one). 
  2. One or more than one EC2 instance with Apache running on them.

What we will do?

  1. Login to AWS
  2. Create an Application Load Balancer and access the Apache Application using DNS of the Load Balancer.

Login to AWS

  1. Click here to go to AWS Login Page.

When we hit the above link, we will see a web page as follows where we are required to log in using our login details.

AWS Login

Once we login into AWS successfully, we will see the main console with all the services listed.

Create  an Application Load Balancer and access the Apache Application using DNS of the Load Balancer

To create an Application Load Balancer, click on "Services" at the top left menu and search for "EC2" and click on the result. 

Create Application Load Balancer

On the main EC2 dashboard, scroll down and click on “Load Balancer” available in the left navigation menu .

Resources

Click on “Create Load Balancer” to create your first load balancer.

Create Load Balancer

To create an Application Load Balancer, select “Application Load Balancer” and click on create. There are two more types of load balancers available in AWS, we are not going to discuss them in this article.

Select balancer type

Type a Name for the load balancer, keep the Scheme as “Internet-facing” so that the load balancer routes requests from clients over the Internet to targets. Keep the other settings unchanged and click on “Next: Configure Security Settings”. 

LB name

Scroll down and select at least two Availability Zones from your VPC. I have selected three of them here. Click on “Next: Configure Security Settings” to proceed.

Load Balancer protocol

Since we have used HTTP and not HTTPS in Listener, in the previous step, we see this warning. For the test environment, we can ignore this but for the production environment, it is recommended to use HTTPS. To proceed with HTTP click on “Next: Configure Security Groups”.

Security settings

Select “Create a new security group”, this will contain the rule that allows traffic to the port that we selected for our load balancer.  If you already have your security group in place, you can choose it by clicking on "Select and existing group". "Click on “Next: Configure Routing”.

Configure security group

Here, specify a name for the target group and keep the rest configuration as is and click on Choose “Next: Register Targets”. Make sure the name here is unique and there is no other target group in this region with the same name.

Configure routing

Here, select one or more instances having apache running on port 80 from the list available and click on “Add to registered”. Click on “Next: Review” to proceed.

Register targets

Review all the configuration here and click on “Create”.

Review settings

Click on Close to close the window and return to the main window of Load Balancer.

Load balancer created successfully

Once the State changes to “active”, we can verify that our targets have passed the initial health check and then test that the load balancer is sending traffic to the instances registered. Copy the DNS name from the description tab. This step may take a few mins so wiat till then.

List of load balancers

Hit the URL you copied in the browser and you can see that the load balancer is sending traffic to the instances with Apache on them.

test page

Conclusion

In this article, we saw the steps to create an Application Load Balancer and register instances to the target group.

Share this page:

Suggested articles

0 Comment(s)

Add comment