Create Classic Loadbalancer In Aws
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 Classic Loadbalancer?
Classic load balance works both on Layer 4 and Layer 7 (Network and Application layers of OSI model).
It is used to distribute the incoming HTTP and HTTPS traffic requests to the target EC2 instances across the availability zones.
Components Of Classic Loadbalancer
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.
We need to configure health checks which is used to check the health of the registered EC2 instances.
And So the load balancer can forward the incoming requests only to the healthy targets.
Creating Classic Load Balancer
To create classic 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 Classic Load balancer , click Create
Step 1: Define Load Balancer
Provide the name for the load balancer,
Choose the VPC you want to the load balancer to be created.
If you check Create an internal load balancer , The loadbalancer will communicate only with the VPC.
Next We need to configure listeners , The Load balancer receives the traffic on port 80 and uses HTTP protocol and forwards the requests to the EC2 instances on port 80.
Next We have to choose different subnets from different Availabilty zone to provide high availability for the load balancer.
Step 2: Assign Security Groups
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 Health Checks
We need to configure health checks so that the load balancer will perform health checks on the target EC2 instances.
And the load balancer will route the traffic only if the EC2 instance passes the health checks.
Under Advanced Details ,
INTERVAL : You can configure how often the health checks should be performed.
RESPONSE TIMEOUT : How long load balancer should wait for the response from the instances.
UNHEALTHY THRESHOLD : When an instance should be considered unhealthy after how many unhealthy thresholds.
Step 4: Adding EC2 Instances
If you want the load balancer to distribute or route the traffic ,
Now we need to register the EC2 instances with the load balancer.
Enable Cross-Zone load balancing and Enable Connection draining to default.
Click Next: Add Tags
Provide a suitable tagging for the load balancer and click Review and Create
Review all the configurations and click Create.
We have successfully configured and created Classic Load balancer using AWS Console.
Step 5: Testing Load Balancer
Select the load balancer , choose Instances ,
You should see the status of the instance to be In service, In order to receive the traffic.
TO test the load balaner ,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 classic 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.