AWS ELB (Elastic Load Balancer)
AWS ELB (Elastic Load Balancer) Complete Guide for Beginners
When users open a website, they expect it to be fast and always available.
But if all users hit only one server, that server can crash.
This is where AWS ELB (Elastic Load Balancer) helps.
ELB automatically distributes traffic across multiple EC2 instances so your application stays fast, stable, and highly available.
What is ELB in AWS
Elastic Load Balancer (ELB) is a service that sits between users and your EC2 servers.
Its job is simple:
It receives traffic from users and sends it to healthy servers.
Instead of sending all traffic to one EC2, ELB spreads it across many EC2 instances.
Why ELB is Needed
Imagine you have:
One EC2 running a website
1,000 users visit at the same time
The server will slow down or crash.
With ELB:
You can have 5 or 10 EC2 instances
Traffic is divided among them
If one EC2 fails, ELB sends traffic to others
This makes your application reliable.
How ELB Works
User sends request to your website
Request goes to ELB
ELB checks which EC2 is healthy
ELB forwards the request to one of them
EC2 sends response back to user
Users never directly talk to EC2. They talk to ELB.
Types of Load Balancers in AWS
AWS provides four types of load balancers.
1. Application Load Balancer (ALB)
Used for:
Web apps
APIs
Microservices
It works at Layer 7 (HTTP/HTTPS).
It can:
Route traffic based on URL
Route based on hostname
Support containers and Kubernetes
2. Network Load Balancer (NLB)
Used for:
Very high traffic
TCP and UDP apps
Low latency systems
It works at Layer 4 and is extremely fast.
3. Gateway Load Balancer
Used for:
Firewalls
Security tools
Traffic inspection
Mostly used in advanced networking.
4. Classic Load Balancer
Old version.
Not recommended for new applications.
What is Target Group
ELB does not directly send traffic to EC2.
It sends traffic to a Target Group.
A Target Group can contain:
EC2 instances
IP addresses
Containers
ELB checks health of targets before sending traffic.
Health Checks
ELB constantly checks if your servers are working.
If an EC2:
Stops responding
Returns error
ELB removes it from traffic.
When it becomes healthy again, ELB adds it back.
This gives automatic failure handling.
Real Example
You have:
3 EC2 running a website
One ALB in front
Users hit:
www.myapp.com → ALB → EC2
If one EC2 crashes:
ALB sends traffic only to the other two
Users never notice the failure
Creating an ELB (Simple Flow)
Open EC2 dashboard
Click Load Balancers → Create Load Balancer
Choose Application Load Balancer
Select VPC and subnets
Create a Target Group
Register EC2 instances
Create the load balancer
Now your app is load balanced.
ELB with Auto Scaling
ELB works perfectly with Auto Scaling.
When traffic increases:
Auto Scaling launches new EC2
ELB starts sending traffic to them
When traffic decreases:
EC2 are removed
ELB updates automatically
This gives fully automatic scaling.
Security with ELB
ELB supports:
HTTPS
SSL certificates
AWS Certificate Manager
This means:
You can secure your website easily
ELB handles encryption
ELB vs EC2 Public IP
Without ELB:
- Users connect to one EC2 IP
With ELB:
Users connect to one stable DNS name
EC2 can be replaced anytime
No downtime
Benefits of ELB
High availability
Automatic failover
Better performance
Easy scaling
Works with Auto Scaling
Final Thoughts
ELB is one of the most important services in AWS.
If you are building:
Websites
APIs
SaaS products
You will almost always use ELB.
It makes your application professional, scalable, and reliable.
All About Load Balancer
What is a Load Balancer
A Load Balancer is a middle layer between users and your servers.
Users never directly connect to EC2.
They connect to the Load Balancer, and the load balancer forwards the request to one of the servers.
Think of it like a traffic police.
User → Load Balancer → EC2 Servers
Its job is:
Distribute traffic
Avoid overload
Send users only to healthy servers
What is a Target Group
A Target Group is a group of backend servers.
These can be:
EC2 instances
IP addresses
Containers
The load balancer does not send traffic directly to EC2.
It sends traffic to a Target Group, and the target group contains your EC2s.
So the flow is:
User → Load Balancer → Target Group → EC2
What is Health Check
Load balancer keeps checking every target.
It sends a request like:
GET /health
If a server responds correctly, it is healthy.
If it fails, load balancer stops sending traffic to it.
This is how AWS automatically avoids broken servers.
Listener
A Listener tells the load balancer:
Which port to listen on
Which protocol to use
Example:
HTTP on port 80
HTTPS on port 443
When traffic comes to port 443, the listener sends it to a target group.
Rules
Rules define how traffic is routed.
Example:
/api → API servers
/images → image servers
/login → auth servers
This is called path based routing and is done using Application Load Balancer.
What is Trust Store
Trust store is used when you want mutual TLS (mTLS).
This means:
Client also sends a certificate
Load balancer verifies it
Trust store is a place where:
You upload trusted CA certificates
Load balancer checks if client certificate is valid
It is used for:
Banking apps
Internal company systems
Secure APIs
SSL Certificate in ELB
ELB supports HTTPS.
You attach:
- SSL certificate from AWS Certificate Manager
ELB does:
Encryption
Decryption
Your EC2 can run normal HTTP but users get HTTPS.
What is Sticky Session
Sticky session means:
- One user always goes to same server
Used when:
- App stores session in memory
Enabled at target group level.
Load Balancer with Auto Scaling
When traffic increases:
Auto Scaling adds EC2
Target group updates automatically
Load balancer sends traffic to new EC2
No manual work needed.
Simple Real Flow
User opens website
→ Request hits Load Balancer
→ Listener receives it
→ Rule checks URL
→ Sends to Target Group
→ Target Group selects healthy EC2
→ EC2 responds
Everything is automatic.
Why Load Balancer is Critical
Without it:
- One server crash = website down
With it:
No single point of failure
High availability
Smooth traffic handling