Lesson 1 of 3 Elastic Load Balancing

Configuring Load Balancers, Listeners and Target Groups

This lesson explains how to choose the right load balancer and configure listeners and target groups correctly, which underpins high availability.

Learning outcomes

After completing this lesson, you will be able to:

  • Choose between ALB, NLB and GWLB.
  • Configure listeners, rules and target groups.
  • Route requests by path and host.

Load balancer types

An Application Load Balancer (ALB) works at layer 7 (HTTP, HTTPS, gRPC). It routes requests with listener rules on host, path, headers, query strings, methods and source IPs, supports weighted target groups, redirects and fixed responses, authentication with Cognito or OIDC, WAF, and targets that are instances, IP addresses or Lambda functions. A Network Load Balancer (NLB) works at layer 4 (TCP, UDP, TLS) with very high throughput and low latency, preserves the client source IP, provides a static IP per AZ (or Elastic IPs), supports security groups, and can front PrivateLink endpoint services. A Gateway Load Balancer (GWLB) distributes traffic to third-party virtual appliances such as firewalls using GENEVE. The Classic Load Balancer is legacy.

TypeLayerChoose for
Application Load Balancer7HTTP/HTTPS routing by path or host, WAF, Lambda targets, authentication
Network Load Balancer4TCP/UDP, extreme performance, static IPs, source IP preservation, PrivateLink
Gateway Load Balancer3Inline virtual appliances (firewalls, IDS)
Sort into groups

ALB or NLB?

Exam skills 2.2.1 · 5.2.3

Choose the load balancer type for each requirement.

Log in to try this activity Interactive activities are free with an account.

Listeners and target groups

A listener checks for connections on a protocol and port and has a default action plus, for ALBs, ordered rules. HTTPS and TLS listeners need a certificate (usually from ACM), a security policy that controls TLS versions and ciphers, and can serve several certificates using SNI. A target group defines the target type, protocol and port, health check settings, and attributes such as deregistration delay (connection draining, default 300 seconds), slow start, stickiness (load balancer-generated or application cookies) and the routing algorithm (round robin, least outstanding requests or weighted random with automatic target weights).

Cross-zone load balancing spreads traffic evenly across all targets in all enabled AZs. It is always on for ALBs (and can be turned off per target group), and off by default for NLBs and GWLBs, where turning it on incurs inter-AZ data charges. With it off, each AZ's load balancer node sends traffic only to targets in its own AZ, which causes uneven load if AZs have different numbers of targets.

300s

Default deregistration delay

Worked example

Routing by path

A company consolidates three services behind one ALB. The HTTPS listener uses an ACM certificate for shop.example.com and the security policy ELBSecurityPolicy-TLS13-1-2-2021-06. Rules forward /api/* to the api target group (ECS tasks, IP targets), /images/* to a target group of EC2 instances, and everything else to the web target group. An HTTP listener on port 80 has a single redirect action to HTTPS with status 301. The API target group uses least outstanding requests because request times vary widely.

Check yourself

Which load balancer provides static IP addresses?

Show answer

Network Load Balancer.

Exam Tips

Remember for the exam

  • ALB for HTTP routing, WAF and Lambda targets; NLB for TCP/UDP, static IPs and PrivateLink.
  • HTTPS listeners need an ACM certificate and a security policy; SNI serves multiple certificates.
  • Deregistration delay drains in-flight requests before targets are removed.
  • Cross-zone load balancing is on for ALB, off by default for NLB.