The Application Load Balancer (ALB) is one of the most versatile and effective services in AWS. This article will cover how to use it for different purposes, including dealing with a large number of requests that can overwhelm a single machine, distributing traffic across multiple servers, and providing redundancy when using multiple EC2 instances.
The blog post intro paragraph can be improved by adding more information about what the reader will learn from reading this blog post.
What is Application Load Balancer (ALB)?
An Application Load Balancer (ALB) is a fully managed service that enables customers to distribute traffic across multiple EC2 instances, HTTP services, or both. ALBs are deployed within your VPC and can be used with Elastic Load Balancing Classic Target Groups or the new Amazon CloudWatch-based Target Group configuration feature introduced in 2014.
An application load balancer (ALB) is a type of network equipment used for distributing web requests among different servers such as those running on an elastic beanstalk environment which allows you to use microservices architecture using clusters stored inside AWScloudwatch.
Benifits of Application Load Balancer Benefits (ALB)
- You can add multiple ports to an EC2 instance so you don’t have to use a port for each service.
- Load balancers allow you to route traffic to multiple servers in different availability zones. They work by selecting the most efficient server from a list of available targets, and then forwarding requests towards that target via IP address or Amazon EC2 instances.
- You can see data about your application’s performance in real time, making it easier to identify and fix issues that are affecting the user experience.
- With the flexibility to change, you are able route more applications on one instance. Additionally, grouping target apps allows inter-app communication in microservices easier than ever before and is useful for a simpler architecture.
- ALB is a more secure service because it uses SSL/TLS certificates, user authentication, and logging combined with the Amazon Virtual Private Cloud.
We will now create a load balancer for the application
- Login to AWS management console.
- Click on EC2 service and scroll down to the load balancers section on the left-hand side.
- Click on Create Load Balancer
- Click on Create Application Load balancer
- Give it a name as “DemoALB” and scroll down and select all the Availability Zones which are given there
- Leave all the settings as it is and click on Next
- In this section give your Target group name as “my-first-target-group”
- Scroll Down and click on Advanced Health check settings
- Configure the settings as shown below figure and click on Next
- In the Register targets section, you will see EC2 instances if you had created them earlier
- If instances are not created, create them quickly by using Amazon Linux2 AMI and launch them.
- Here I had already created instances so I will select both of them and click on Add to register.
- Click on Create
- Wait for ALB to come to Active state from Provisioning
- Now copy the DNS name and paste it in New Tab and you will see a “Hello World” message
- We can have multiple listeners which can redirect to multiple target groups
- Here we have one listener which is forwarding to my-first-target-group
- We will create another Target group
- Click on Create target group
- Give it a name as “my-second-target-group”
- Scroll down and click on Advanced Health check settings and configure it as shown in the below figure
- Click on Next and select any instance and click on Include pending below.
- Click on Create Target Group.
- In our ALB click on Listeners tab
- We can have multiple listeners redirecting to multiple target groups
- Here we have one listener on Port 80 which is forwarding to my-first-target-group
- Click on View/edit rules of this listener to start leveraging other target groups
- Click on the + symbol present above and then click on the Insert rule
- Now there are 2 conditions “IF” and “THEN”
- In IF– Click on Add condition then select Path and in value type /test
- In THEN click on Add condition and select Forward to then select my-second-target-group
- Click on Save
- So, we have 2 rules, first one is evaluated as a path and target is my-second-target-group if it matches
- Else by default, it should route to my-first-target-group
- So here we can add rules and paths and show that Application Load Balancer is way more powerful than Classic Load balancer
Congratulations!! You have created your Application load balancer, see you in the next lab.