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. Elastic Load Balancer provides three types of load balancers:
Application Load Balancer (ALB): An Application Load Balancer operates at layer 7 of the Open Systems Interconnection (OSI) model. The ALB is designed for applications that primarily use HTTP/HTTPS protocols. It supports advanced features like HTTP/2, request routing based on URLs, methods, headers, and SSL/TLS termination.
Network Load Balancer (NLB): Network Load Balancer operates at layer 4 of the Open Systems Interconnection (OSI) model. The NLB is optimized for TCP and UDP protocols and is well-suited for microservices, containerized applications, and high-performance applications that require low-latency traffic delivery. It supports IP address-based routing, port-based routing, and connection tracking.
Classic Load Balancer (CLB): The Classic Load Balancer is a simpler and less feature-rich type of load balancer. The CLB operates at layer 4 of the Open Systems Interconnection (OSI) model. It is primarily used for legacy applications that are incompatible with the more modern ELB types.
Task 1: Launch 2 EC2 instances with an Ubuntu AMI and use User Data to install the Apache Web Server.
Modify the index.html file to include your name so that when your Apache server is hosted, it will display your name also do it for 2nd instance which includes " TrainWithShubham Community is Super Awesome :) ".
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.
Task 2: Create an Application Load Balancer (ALB) in EC2 using the AWS Management Console.
Add EC2 instances which 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.
- Create a new security group or choose an existing one.
Configure Routing: Create a new target group or choose an existing one.
Register Targets:
- Add the EC2 instances you launched in Task 1 to the ALB as target group.
- Review and Create: Review your settings and click "Create target group."
Verify Target Health:
Go to the "Target Groups" section in the EC2 dashboard. Click on the target group associated with your ALB.
Verify that the status of your EC2 instances is "healthy."
- Test Load Balancing: Copy the DNS name of your ALB (can be found in the "Description" tab). Open a web browser and paste the DNS name in the address bar.
- Refresh the page, and you should see the different responses from your two instances, indicating that the ALB is distributing traffic.