# Elastic Load Balancing: ALB and NLB

> Distribute traffic across healthy targets with Application and Network Load Balancers, target groups, health checks and HTTPS listeners. Free notes, key...

Canonical: https://www.internhack.in/roadmaps/tracks/cloud-engineer/load-balancers
Last updated: 2026-11-28

Distribute traffic across healthy targets with Application and Network Load Balancers, target groups, health checks and HTTPS listeners.

Intermediate · about 4 hours · difficulty 3/5

Learn first: [EC2 Instances, AMIs and Pricing Options](https://www.internhack.in/roadmaps/tracks/cloud-engineer/ec2-fundamentals)

A load balancer gives users one stable address, spreads requests across many servers, and stops sending traffic to unhealthy ones.

### Types of Elastic Load Balancer

- **Application Load Balancer (ALB)**: Layer 7 (HTTP/HTTPS). Routes by path (/api), host (api.example.in), headers or query strings. Supports WebSockets, gRPC and authentication with Cognito or OIDC. The default choice for web apps.
- **Network Load Balancer (NLB)**: Layer 4 (TCP/UDP/TLS). Very high throughput, static IPs per AZ, preserves client IP. Use for non-HTTP protocols or when you need fixed IPs.
- **Gateway Load Balancer**: for inserting third-party firewalls and appliances.

### Core concepts

- **Listeners** (port and protocol) have **rules** that forward to **target groups**.
- Targets can be instances, IPs, Lambda functions or ECS tasks.
- **Health checks** decide which targets get traffic. Point them at a lightweight /health endpoint.
- Terminate **HTTPS** at the ALB with a free ACM certificate and redirect HTTP to HTTPS.
- Place load balancers in public subnets across at least two AZs; targets stay private.

Azure Application Gateway and Load Balancer, and Google Cloud Load Balancing are the equivalents.

### Pitfalls

- Health checks that hit a heavy page or require login, so every target is marked unhealthy.
- Target security groups that do not allow traffic from the ALB's security group.
- Leaving an ALB running after a lab: it bills every hour.

You are ready to move on when you can put two instances in private subnets behind an HTTPS ALB and watch traffic shift when you stop one.

## Key concepts

- **ALB vs NLB vs GWLB**
- **Listeners and rules**
- **Target groups**
- **Health checks**
- **HTTPS with ACM**
- **Path and host based routing**
- **Sticky sessions**
- **Connection draining**

## Mini project

Put two free-tier instances in private subnets behind an ALB with path-based rules (/ to one, /api to another). Stop one instance and watch the health check fail over. ALBs are billed hourly beyond free tier limits, so finish within a couple of hours and delete the ALB, target groups and instances.

## Check yourself

Your ALB returns 502 errors for every request. Name three likely causes.

## Free resources

- [Elastic Load Balancing documentation](https://docs.aws.amazon.com/elasticloadbalancing/) (AWS)
- [What is an Application Load Balancer?](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html) (AWS)

Previous: [Operating EC2 with Systems Manager](https://www.internhack.in/roadmaps/tracks/cloud-engineer/ec2-operations) · Next: [Auto Scaling Groups and Launch Templates](https://www.internhack.in/roadmaps/tracks/cloud-engineer/auto-scaling)

## More in Compute: EC2, Auto Scaling and Load Balancing

- [EC2 Instances, AMIs and Pricing Options](https://www.internhack.in/roadmaps/tracks/cloud-engineer/ec2-fundamentals)
- [Operating EC2 with Systems Manager](https://www.internhack.in/roadmaps/tracks/cloud-engineer/ec2-operations)
- [Elastic Load Balancing: ALB and NLB](https://www.internhack.in/roadmaps/tracks/cloud-engineer/load-balancers)
- [Auto Scaling Groups and Launch Templates](https://www.internhack.in/roadmaps/tracks/cloud-engineer/auto-scaling)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Cloud Engineer (AWS) Roadmap](https://www.internhack.in/roadmaps/tracks/cloud-engineer)
