?? Day 41: Setting up an Application Load Balancer with AWS EC2 ??
Today on our #90DaysofDevOps journey, we explored the critical concept of Load Balancing in AWS EC2, ensuring that our applications are reliable and can handle varying loads efficiently.
What is Load Balancing?
Load balancing is the process of distributing incoming network traffic across multiple servers. This ensures no single server bears too much load, improving application reliability and performance. It is essential for large-scale, scalable computing systems.
Elastic Load Balancing (ELB):
Elastic Load Balancing (ELB) is an AWS service that automatically distributes incoming application traffic across multiple EC2 instances. ELB provides three types of load balancers:
1. Application Load Balancer (ALB): Operates at layer 7 of the OSI model, ideal for applications that require advanced routing and microservices.
2. Network Load Balancer (NLB): Operates at layer 4, suitable for applications that require high throughput and low latency.
3. Classic Load Balancer (CLB): Operates at layer 4, providing basic load balancing features.
Tasks Completed:
Task 1: Launch EC2 Instances and Install Apache
1. Launch 2 EC2 Instances:
- Used Ubuntu AMI.
- Configured the instances with a User Data script to install the Apache Web Server and customize the index.html file.
User Data Script for First Instance:
#!/bin/bash
sudo apt update -y
sudo apt install apache2 -y
echo "Your Name" > /var/www/html/index.html
User Data Script for Second Instance:
```sh
领英推荐
#!/bin/bash
sudo apt update -y
sudo apt install apache2 -y
echo "TrainWithShubham Community is Super Awesome :)" > /var/www/html/index.html
```
2. Access the Web Pages:
- After the instances were running, copied their public IP addresses.
- Pasted the IP addresses into a web browser to verify the custom messages in the index.html files were displayed.
Task 2: Create an Application Load Balancer (ALB)
1. Set Up ALB:
- Opened the AWS Management Console and navigated to the EC2 Dashboard.
- Created an Application Load Balancer.
2. Configure Target Groups:
- Created a target group and registered the two EC2 instances launched in Task 1.
3. Attach Target Groups to ALB:
- Added the target group to the ALB.
4. Verification:
- Checked the health status of the target instances in the AWS Management Console to ensure they were healthy.
- Accessed the ALB's DNS name in a web browser to verify load balancing. The ALB distributed traffic between the two instances, displaying the respective index.html messages.
By setting up an Application Load Balancer, we've significantly improved the reliability and performance of our application. This ensures that our application can handle increased traffic and continue to function smoothly, even if one of the instances goes down.
Excited to leverage this knowledge to build more scalable and resilient applications in the cloud! ???? #AWS #EC2 #LoadBalancing #DevOps #CloudComputing #LearningJourney
---
Feel free to personalize this post before sharing it on LinkedIn!
DevOps Engineer at Capgemini
8 个月Happy Learning!!