PRACTICAL SCENARIO
At TechNova, we recently launched a product website hosted on Amazon EC2. To ensure high availability and fault tolerance, I was tasked with configuring an Application Load Balancer (ALB) that distributes traffic across two EC2 instances in different Availability Zones.
Objective
✅ Set up an Application Load Balancer
✅ Launch two EC2 instances in different Availability Zones
✅ Register both instances with the Target Group
✅ Ensure traffic is distributed evenly
Step-by-Step Implementation
1. Launch Two EC2 Instances
Choose the same region, but different subnets (AZs)
Use the same AMI (Amazon Linux), security group, and key pair for simplicity.
Connect to each instance via SSH
*Then install Web Server *
*Run this commands: *
sudo yum install httpd -y
sudo systemctl start httpd
echo "Welcome to Web Server 1" | sudo tee /var/www/html/index.html
Repeat on the second instance with "Web Server 2"
Install a web server (e.g., Apache or NGINX) with simple HTML content on both
2. Create a Target Group
Navigate to Target Groups
Choose:
Target type: Instance
Protocol: HTTP
Port: 80
Register both instances (tick the boxes)
3. Set Up the Application Load Balancer
Navigate to Load Balancers
Choose Application Load Balancer
Configure:
Name your Application Load Balancer
Scheme: Internet-facing
Availability Zones: Select at least two with their subnets
Listeners: HTTP (port 80)
Then attach your Target Group
*Review and create *
To Test the Application Load Balance
Visit the DNS name of the ALB in a browser
Refresh several times you should see responses from both instances
Congratulation, You have successfully set up load balancing!
Challenge Faced
At first, only one instance was receiving traffic. After reviewing the Target Group health checks, I discovered the web server was installed but not properly configured on the second instance.
A quick fix in the index.html resolved the issue.
CONCLUSION
With an Application Load Balancer in place, TechNova’s website can now handle more traffic and stay resilient in case of instance or AZ failures. This setup is foundational for achieving high availability in AWS.
Have you tried setting up an ALB before? Let me know your experience or any challenges you faced in the comments!
Top comments (0)