If you are running an application on a single EC2 instance, you have a single point of failure. If that server goes down, your website goes down with it. This is where AWS Elastic Load Balancing (ELB) comes into play.
Recently, I spent time focusing purely on AWS ELB to understand how traffic is distributed, how health checks work, and how to achieve high availability. Here is a simple breakdown of my hands-on experience.
The Core Concept: Distributing Traffic
A Load Balancer sits in front of your servers and acts like a traffic cop. When users visit your website, they hit the Load Balancer, which then forwards the request to one of your backend EC2 instances.
ALB vs. NLB: What’s the Difference?
During my labs (like "Introduction to Elastic Load Balancing" and "Working with Elastic Load Balancing"), I got hands-on with two main types:
- Application Load Balancer (ALB): This works at the application layer (Layer 7). It's smart—it can route traffic based on the URL path (e.g., sending
/images traffic to one server and /api to another). It’s perfect for web applications.
- Network Load Balancer (NLB): This works at the network layer (Layer 4). It’s ultra-fast and handles millions of requests per second, but it doesn't look at the URL, just the IP and port.
My Real-World Practice Setup
Alongside the Skill Builder labs, I decided to build an architecture myself in the AWS Console:
- I launched two EC2 instances with a basic web server installed.
- I created an Internet-facing ALB and set up a Target Group.
- I registered both EC2 instances into the target group.
The Magic of Health Checks
This is the most important part. A Load Balancer doesn't just blindly send traffic; it constantly asks the servers, "Are you okay?" (Health Checks).
When I registered my instances, I watched their status go from Initial to Healthy . This meant the ALB was successfully communicating with them.
Testing High Availability
To prove the architecture actually works, I did a failover test. I stopped one of my EC2 instances.
- The ALB's health check immediately failed for that instance.
- The ALB stopped sending traffic to the dead server.
- The website remained fully accessible because the ALB automatically routed all traffic to the healthy instance.
Troubleshooting the "Why is my site down?" Issue
I also did a lab on "Troubleshooting Website Reachability behind a Load Balancer." This taught me that if your site is unreachable, the problem usually lies in one of three places:
- Security Groups: Is the ALB allowing HTTP/HTTPS from the internet? Is the EC2 security group allowing traffic only from the ALB's security group? (Least Privilege principle).
- Listener Ports: Is the ALB listening on port 80, and is it forwarding to port 80 on the EC2?
- Target Health: If the targets are
Unhealthy , the ALB will return a 503 Service Unavailable error.
Final Thoughts
Setting up an ELB and breaking it to see how it reacts is the best way to learn. Using least-privilege security groups and understanding how traffic flows from the ALB to the target group is a must-know skill for any Cloud Engineer or Solutions Architect.
If you are learning AWS, I highly recommend building an ALB with two servers and playing with the health checks. It makes the theory click instantly!
Loading article