*Please download resources before you proceed with the steps.
In AWS, Elastic Load Balancer(ELB) routes traffic from inbound applications to many destinations, including Amazon EC2 instances, containers, IP addresses, and Lambda functions. In a single availability zone or several availability zones helps you to regulate the variable load of your application’s traffic. Elastic Load Balancing provides three types of load balancers – Application Load balancer(ALB), Network Load Balancer(NLB), and Classic Load Balancer(CLB) which provides the high availability, automated scalability, and security required to make your applications error-tolerant. Here we will learn about Classic load Balancer and how to implement it in AWS.
Classic Load Balancer ( CLB )
The Classic Load Balancer operates at both the request and connection levels and provides basic load balancing in many Amazon EC2 instances. It’s intended for use with EC2-Classic-based applications. CLB gives you benefits in the following ways:-
- Provides Support to TCP and SSL listeners.
- Support to Sticky Session.
- Support to EC2- Classic.
Steps to create EC2 instances for CLB:-
- Open AWS Management Console and search EC2.
- Click on Instances in the left sidebar.
3. Click on Launch Instances.
4. In Step 1: Choose AMI, select Amazon Linux 2 AMI (HVM), SSD Volume Type.
5. In Step 2: Choose an Instance Type, select t2 micro (free tier eligible) and then next.
6. In Step 3: Configure Instance details, give number of instances as 2.
7. In User Data, add or copy/paste the code for your application to run and click next.
8. Skip to Step 5: Add Tags, select Add Tags and give key and its value. Click Next.
9 . In Step 6: Configure Security Groups, give a unique Security Group Name and description. Click on Add Rule and select HTTP from the dropdown menu. In source, choose custom or anywhere to make the application visible to everyone from anywhere.
Click on Review and Launch.
10 . In Step 7: Review Instance Launch, click Launch and then Launch Instances.
In Instances section you can see the 2 instances created. You can try running these applications by copying their public IPv4 addresses in the browser.
Your application would look like this:-
Now, we will create a Classic Load Balancer (CLB) and connect it with both of these application servers.
Steps to create Classic Load Balancer(CLB):-
- In EC2 dashboard, click on Load Balancers in the left sidebar.
2. Click on Create Load Balancer and then in Select Load Balancer Type, click Create under Classic Load Balancer.
3. In Step 1: Define Load Balancer, give CLB a unique name, leave all other settings as default and click Next.
4. In Step 2: Assign Security Groups, create a new Security Group and give it a name and description. Add HTTP protocol to it and then click Next.
5. Skip to Step 4. In Advanced Details, set Interval time as 10 seconds. Click Next.
6. In Step 5: Add EC2 Instances, select all the instances you want to add in the load balancer.
7. In Step 7, Review and Create the Classic Load Balancer. Click Create.
You have successfully created your first Classic Load Balancer. To check it’s working, you first need to check your all the instances are working.
To access your application using CLB, copy and paste the DNS name from the description to the new browser and run it. You can observe getting responses from different IPs by refreshing the page after every 10 seconds.
Your applications output will look like:-
You can observe 2 different IPs being accessed using the same link( DNS name).
Congratulations! You have configured how to use Classic Load Balancer.