Table of contents
What is Load Balancing?
- Load balancing is the distribution of workloads across multiple servers to ensure consistent and optimal resource utilization. It is an essential aspect of any large-scale and scalable computing system, as it helps you to improve the reliability and performance of your applications.
Elastic Load Balancing
Elastic Load Balancing (ELB) is a service provided by Amazon Web Services (AWS) that automatically distributes incoming traffic across multiple EC2 instances.
ELB provides three types of load balancers:
- Application Load Balancer (ALB) - operates at layer 7 of the OSI model and is ideal for applications that require advanced routing and microservices.
- Network Load Balancer (NLB) - operates at layer 4 of the OSI model and is ideal for applications that require high throughput and low latency.
- Classic Load Balancer (CLB) - operates at layer 4 of the OSI model and is ideal for applications that require basic load balancing features.
Task 1
launch 2 EC2 instances with an Ubuntu AMI and use User Data to install the Apache Web Server.
Log into your AWS Console and go to the EC2 dashboard.
Click on the "Launch Instance" button and select "Ubuntu Server ".
Choose the instance type, configure the instance details, add storage, and configure security groups as required.
In the "Configure Instance Details" page, scroll down to the "Advanced Details" section and expand the "User data" field.
In the "User data" field, enter the following commands to install and start the Apache web server:
#!/bin/bash apt-get update apt-get install -y apache2 systemctl start apache-2 systemctl enableapache-2
In summary, give a number of Instance 2 and click on Lunch Instance.
You can see two instances are created.
Copy the public IP address of your EC2 instances.
Open a web browser and paste the public IP address into the address bar.
You should see a webpage displaying information about your PHP installation.
Apache Server 1.
Apache Server 2.
Modify the index.html file to include your name so that when your Apache
the server is hosted, it will display your name also do it for 2nd instance which includes " DevOps Community is Super Awesome :) ".
Connect Instances using SSH.
Go inside the/var/www/html path and edit the index.html file
Task 2:
Create an Application Load Balancer (ALB) in EC2 using the AWS Management Console.
Add EC2 instances that you launch in task-1 to the ALB as target groups.
Verify that the ALB is working properly by checking the health status of the target instances and testing the load-balancing capabilities.
Log in to the AWS Management Console and go to the EC2 dashboard.
Click on "Load Balancers" in the left-hand navigation menu and then click the "Create Load Balancer" button.
Select "Application Load Balancer" as the load balancer type and click "Create".
Configure the load balancer settings, such as name, listener, security group, and availability zones. For the listener, you can choose HTTP or HTTPS, depending on your application's requirements.
Configure "Security Groups"
Now in the Listeners and routing Section there, you find the select target group but we don't have the Target group So we click on Create Target Group and it will take you to a new browser. Now you have to Select Target Type as an Instance Because we use our ec2 instance for load balancing. If you want to set with ip select that. There are 4 Target types. Now enter the Target group name.
Scroll Down to the bottom and click on Next. Now you see There is your all-running instance so you have to select instance for load balancing And click on Include as pending below
Now you have the option to review targets review and click on Create Target Group
Back go to the browsers Load Balancer tab and refresh the target group section and there you will find the target group that you created now select that.
Scroll down and there you will see the summary about the load balancer review it and click on Create the load balancer.
Now you Successfully Created a Load balancer for the EC2 instance. click on view load balancer and see the all things about your Load balancer.
Now it Its Time to test your Load Balancer. Copy the DNS name from the Load balancer Description and paste it into a new browser tab.
Thankyou....