Building highly available applications is no longer optional it’s expected. Whether you’re running a startup app or an enterprise system, downtime can cost users, revenue, and trust. One of the simplest and most effective ways to improve availability is by using a load balancer.
In this guide, you’ll learn how to set up a load balancer on AWS step by step, even if you’re a beginner. By the end, you’ll have a working setup that distributes traffic across multiple servers and keeps your application resilient.
Table of Contents
ToggleWhat is a Load Balancer?
A load balancer acts as a traffic controller. Instead of sending all user requests to a single server, it distributes them across multiple servers.
Why this matters:
- Prevents server overload
- Improves application performance
- Ensures high availability
- Handles traffic spikes efficiently
On AWS, the most commonly used service is the Application Load Balancer (ALB), part of Elastic Load Balancing (ELB).
Prerequisites
Before we start, make sure you have:
- An AWS account
- Basic knowledge of cloud computing
- Access to the AWS Management Console
- At least two EC2 instances (for redundancy)
Step 1: Launch EC2 Instances
We’ll begin by setting up two servers that your load balancer will distribute traffic to.
Steps:
- Go to EC2 Dashboard
- Click Launch Instance
- Choose an Amazon Machine Image (AMI), like Amazon Linux
- Select instance type (t2.micro is fine for testing)
- Configure:
- Allow HTTP (port 80) in security group
- Launch at least two instances
Step 2: Install a Web Server
Connect to each instance via SSH and install a simple web server.
sudo yum update -y sudo yum install nginx -y sudo systemctl start nginxCustomize each server
On Instance 1:
echo “Hello from Server 1” | sudo tee /usr/share/nginx/html/index.htmlOn Instance 2:
echo “Hello from Server 2” | sudo tee /usr/share/nginx/html/index.htmlThis helps you verify traffic distribution later.
Step 3: Create a Target Group
A target group is a collection of servers that receive traffic from the load balancer.
Steps:
- Go to EC2 → Target Groups
- Click Create Target Group
- Choose:
- Target type: Instances
- Protocol: HTTP
- Port: 80
- Give it a name (e.g.,
my-target-group) - Register your EC2 instances
Step 4: Create an Application Load Balancer
Now we’ll create the load balancer itself.
Steps:
- Go to EC2 → Load Balancers
- Click Create Load Balancer
- Choose Application Load Balancer
- Configure:
- Name:
my-load-balancer - Scheme: Internet-facing
- IP type: IPv4
- Name:
Network mapping:
- Select your VPC
- Choose at least two subnets in different Availability Zones
Security group:
- Allow HTTP (port 80)
Step 5: Configure Listeners and Routing
Listeners define how traffic is handled.
Default setup:
- Protocol: HTTP
- Port: 80
- Forward to: your target group
Step 6: Register Targets
If not already done:
- Add your EC2 instances to the target group
- Ensure health checks are passing
Step 7: Configure Health Checks
Health checks ensure traffic only goes to healthy servers.
Default settings:
- Protocol: HTTP
- Path:
/ - Interval: 30 seconds
You can customize thresholds depending on your application.
Step 8: Access Your Load Balancer
Once created, AWS provides a DNS name like:
my-load-balancer-123456789.us-east-1.elb.amazonaws.comPaste it into your browser.
What you should see:
Refreshing the page should alternate between:
- “Hello from Server 1”
- “Hello from Server 2”
That means your load balancer is working!
Step 9: Enable Auto Scaling (Optional but Recommended)
To make your system truly highly available, combine load balancing with Auto Scaling.
Benefits:
- Automatically adds instances during high traffic
- Removes instances when demand drops
- Saves cost while maintaining performance
Step 10: Add HTTPS (SSL/TLS)
For production use, always secure your application.
Steps:
- Go to AWS Certificate Manager (ACM)
- Request a certificate
- Add HTTPS listener (port 443) to your load balancer
- Attach the certificate
Step 11: Monitor Your Load Balancer
Use CloudWatch to track performance.
Key metrics:
- Request count
- Latency
- Healthy host count
- HTTP error rates
Step 12: Clean Up Resources
To avoid charges:
- Terminate EC2 instances
- Delete load balancer
- Delete target groups
Key Concepts Recap
- Load Balancer: Distributes traffic across servers
- Target Group: Group of instances receiving traffic
- Listener: Defines how requests are routed
- Health Check: Ensures only healthy servers receive traffic
Common Beginner Mistakes
1. Instances not in multiple AZs
High availability requires multiple availability zones.
2. Security group misconfiguration
Ensure ports 80/443 are open.
3. Health checks failing
Incorrect path or port can mark instances unhealthy.
4. Not using Auto Scaling
Limits your system’s ability to handle traffic spikes.
Real-World Architecture Example
A typical production setup:
- Load Balancer (ALB)
- Auto Scaling Group (multiple EC2 instances)
- RDS database
- CloudWatch monitoring
- Route 53 for DNS
Final Thoughts
Setting up a load balancer on AWS is one of the most important steps toward building a reliable, scalable application.
At a high level, the process is simple:
- Launch multiple servers
- Group them into a target group
- Create a load balancer
- Route traffic intelligently
- Monitor and scale
Once you understand this workflow, you can design systems that handle real-world traffic with confidence.
High availability isn’t just about uptime it’s about delivering a consistent experience to your users, no matter what happens behind the scenes.



