Hello all ! I belive your exploration of the launch template and instances in EC2 was insightful with last session. Today, let's delve into a crucial EC2 concept: Load Balancing.
What is Load Balancing?
Load balancing involves spreading workloads across numerous servers to maintain consistent, efficient resource usage. It's a critical facet of expansive, scalable computing systems, enhancing application reliability and performance.
Exploring AWS Load Balancers: Orchestrating Digital Traffic Flow
Often overlooked, load balancing is the silent force behind smooth user experiences and top-notch availability in modern web apps. Let's uncover the enchantment within AWS Load Balancers today!
AWS provides a range of load balancing options, including Application Load Balancers (ALB), Network Load Balancers (NLB), and Classic Load Balancers (CLB). These tools distribute incoming traffic across multiple targets, such as EC2 instances or containers, to optimize performance, enhance security, and maintain uptime.
Amazon Web Services (AWS) offers Elastic Load Balancing (ELB), a service designed to automatically distribute incoming traffic across multiple EC2 instances. ELB encompasses three load balancer types:
Application Load Balancer (ALB) - Functions at layer 7 of the OSI model, catering to applications needing advanced routing and microservices.
Network Load Balancer (NLB) - Operates at layer 4 of the OSI model, optimized for applications necessitating high throughput and minimal latency.
Classic Load Balancer (CLB) - Functions at layer 4 of the OSI model, suitable for applications requiring fundamental load balancing functionalities.
Lets explore concept with help of task.
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 include " TrainWithShubham Community is Super Aweasome :) ".
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.
Solution
Step 1: we are creating 2 EC2 instance with the help of template.
Setp 2: In user data section we provide below scripts so we'll get apache installed with every new system
Step 3: lets trigger instance with help of template and change index.html for each instance and check output by putting public ip in browser window.
Instance 1 homepage:
Instance 2 homepage
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.
Solution
Step 1: lets create apache-ALB.
Mention target group by creating new one with adding our newly created instance.
Post create load balancer hit button check ALB details in console.
Step 2: verify the ALB with ALB DNS name.
Now will increase load on server2 and check whether traffics is redirected to server 1 or not
Increased load on server using stress. lets again check ALB DNS whether traffics is redirected or not.
Hurrey...!!! we are successfully redirected the traffic to server 1 using Application load balancer.
I hope this article helps you to understand how to balance load using ALB.
Thanks,
Kishor Chavan
I