A Load balancer is used to distribute the traffic coming from the clients across multiple targets which ensures the high availability of the applications.
It’s the single and primary point of contact for the requests from the clients.
What Is Application Load Balancer?
Application load balancer is used to balance the load of HTTP and HTTPS traffic and It works at the Layer 7 which is Application layer of the OSI model.
Components Of Application Loadbalancer
We can register one or more targets in the target group and the targets be EC2 Instances.
The target group will take care of routing the traffic to the registered EC2 Instances based on the protocol and the port number configured.
And each target can be registered with multiple target groups.
We can configure a listener in the load balancer to check health of the targets on each target groups.
Listeners are used to check for the requests from the clients based on the port and the protocol we configured.
We can add a rule in the listener and based on that the traffics are routed to the target instances.
And these rules works based on the rule number and of high priority.
Creating Application Load Balancer:
To create application load balancer , Go to EC2 CONSOLE
under Load Balancing , Click Load Balancers
Click Create Load Balancer , You will asked to choose the type of loadbalancer you want
Select Application Load balancer , Click Create
Step 1: Configure Load Balancer
Provide a name for the load balancer ,
And select the schema ,
If you choose internet-facing , then the load balancer will have a publicaly resolvable DNS and IP Address.
So the clients can sent a request to the applications backed by the load balancer over the internet.
If you choose Internal , It will have only the Private IP Address and the client cannot connect to it.
It can route the traffic within the VPC and it can only route the traffic to the EC2 Instances with Private IP Addresses.
We will create internet-facing load balancer for this tutorial.
next we will configure , On what protocol and on which port should the client send the requests to the load balancer so that load balancer will accept it and route the traffic to EC2 instances.
Next Select the VPC and the availability zones where the load balancer will be created.
Step 2: Configure Security Settings
Click Next: Configure security groups
You can create a new security group or select an existing security group
If you’re allowing traffic on port 80 , Then port 80 should be allowed in the security group.
Step 3: Configure Routing
Here we need to create a target group and select the target type and the protocol and the port in which loadbalaner should sent the traffic to the registered EC2 instances.
And configure health checks on the targets using the health check settings.
you can customize the health check settings as required.
Step 4: Registering Targets
We have to add the EC2 Instances into the Target groups.
To do so , Select the instance Under Instances and click Add to registered.
After doing that , You should see the instance registered under Registered targets.
Click Next: Review , Review the configurations and click Create.
The new load balancer should be in the provisioning state. The state will be changed to Active Once it is completely created.
Your registered instances should be healthy to accept the traffic from load balancer.
Step 5: Testing Load Balancer
To check that , Under Load balancing , Choose Target groups ,
Select the target group and click Targets
And you should see the instance to be Healthy in order to accept the requests.
If you found that the status of the instance is in initial state , It is still in the process of registering the instance in the Target group.
Also the health of the instance may fail due to health check configurations.
Once the instance is healthy and ready.
To verify the load balancer , Click Load balancers and select the load balancer,
You should copy the DNS name of the Load balancer Under the description of Load balancer.
Paste the DNS name in the browser and you should see the default page of the application or web server.
We have successfully created a application load balancer and configured target groups , registered targets and security groups.
Thanks for reading this article , Hope you find it helpful.
Please do check out my other publications.