Routing HTTP Traffic with an Application Load Balancer
This lesson explains the Application Load Balancer, the default for HTTP and HTTPS applications, as part of choosing the right load balancer, one of the most frequently tested decisions in the exam.
Learning outcomes
After completing this lesson, you will be able to:
- Choose between the types of load balancer.
- Explain how ALB listener rules route requests.
- Choose between internet-facing and internal schemes.
- Describe how access logs and metrics monitor an ALB.
Choosing a load balancer
Elastic Load Balancing offers three types of load balancer, which work at different network layers. An Application Load Balancer (ALB) works at layer 7 and understands HTTP, HTTPS, HTTP/2, gRPC and WebSockets. It can route by the content of each request, authenticate users and use AWS WAF. Targets see the client's address in the X-Forwarded-For header, because the ALB opens its own connection to them.
A Network Load Balancer (NLB) works at layer 4, forwarding TCP, UDP and TLS connections with very high throughput and low latency. It provides static IP addresses, preserves the client's IP address and can expose a service through AWS PrivateLink. A Gateway Load Balancer (GWLB) works at layer 3, sending IP packets, encapsulated with the GENEVE protocol, to fleets of security appliances, such as firewalls, so they can inspect traffic transparently. The following table summarises the three types.
X-Forwarded-For headerThe Classic Load Balancer is legacy. All are managed, scale automatically and span the AZs you enable.
The following diagram summarises the three types by layer.

ALB, NLB or GWLB?
Routing and features
An ALB's listener rules examine each request and route it by host name, path, HTTP header, method, query string or source IP address, so one load balancer can serve api.example.com and www.example.com, or send /orders/* and /users/* to different services. A rule's action can forward the request to a target group, or to several weighted target groups for blue/green and canary releases, redirect it, for example from HTTP to HTTPS, or return a fixed response.
An ALB can authenticate users with Cognito or any OpenID Connect provider before requests reach the targets, so applications receive only signed-in users. Targets can be instances, IP addresses, including servers on premises, Lambda functions, and containers using dynamic ports. HTTPS listeners use ACM certificates, and several certificates on one listener serve different domains through SNI. The ALB integrates with AWS WAF and has its own security groups. The following table summarises these features.
| Feature | Detail |
|---|---|
| Listener rules | Route by host, path, HTTP header, method, query string or source IP |
| Actions | Forward (to one or weighted target groups), redirect (such as HTTP to HTTPS), fixed response |
| Authentication | Cognito or OIDC authentication before requests reach targets |
| Targets | Instances, IPs (including on premises), Lambda functions, containers with dynamic ports |
| TLS | ACM certificates, multiple certificates per listener with SNI |
| Security | AWS WAF integration; security groups on the load balancer |
The following diagram shows one listener routing requests with several kinds of rule.

ALB capabilities
Internet-facing or internal
Every load balancer has a scheme, chosen at creation. An internet-facing load balancer has public IP addresses and nodes in public subnets, and its DNS name resolves to those public addresses, so it is the public entry point for an application. Its targets can still sit in private subnets, because the load balancer reaches them over private addresses.
An internal load balancer has only private IP addresses, so it can be reached only from within the VPC, from connected VPCs or from on premises over VPN or Direct Connect. It suits traffic between the tiers of an application, such as from a web tier to an application tier, and internal services that should never be exposed to the internet. The following table summarises the two schemes.
| Scheme | IPs | Use for |
|---|---|---|
| Internet-facing | Public, in public subnets | Public entry points |
| Internal | Private only | Between tiers, or services reached over VPN |
Load balancer schemes
Monitoring
Access logs in S3 record client IP, latency, path and response code per request. CloudWatch metrics such as HTTPCode_Target_5XX_Count, TargetResponseTime and UnHealthyHostCount drive alarms. The ALB's IP addresses change, so clients must use its DNS name.
A load balancer for each workload
Each type of load balancer suits a different workload. The following table identifies the appropriate load balancer for several workloads and the reason in each case.
| Workload | Load balancer | Why |
|---|---|---|
Website with /api and /images handled by different services | ALB | Path-based routing at layer 7 |
| Millions of TCP connections per second for a trading platform | NLB | Layer 4, very high performance, low latency |
| Customers need static IP addresses to allow-list | NLB | One static (or Elastic) IP per AZ |
| Route all traffic through a fleet of third-party firewalls | GWLB | Transparent insertion of appliances |
| HTTP/2 and gRPC microservices | ALB | Supports gRPC and HTTP/2 |
If a question needs both static IPs and HTTP routing, a common answer is an NLB in front of an ALB, or Global Accelerator in front of the ALB.
How does an application behind an ALB find the client's IP address?
Show answer
From the X-Forwarded-For header, because the ALB opens its own connection to the target.
Exam Tips
Remember for the exam
- For path-based or host-based routing, HTTP features or Lambda targets, use an ALB.
- To authenticate users before they reach the application without code, use ALB authentication with Cognito or OIDC.
- For a load balancer between internal tiers, use an internal ALB.
- To analyse the client IP address and latency of every request, use ALB access logs in S3.
- To redirect HTTP to HTTPS, add a redirect action on the HTTP listener.