Reliability and Continuity · Topic 2 of 5

Load Balancing and Multi AZ Design

Choose between Application, Network and Gateway Load Balancers, set health checks and cross zone behaviour, and design for an Availability Zone failure.

  • 5 min
In a nutshell
  • An AZ is an isolated location inside a Region, and a highly available design uses at least two.
  • ALB is Layer 7 with content based routing, and NLB is Layer 4 with static IPs and low latency.
  • GWLB inserts third party virtual appliances into the traffic path.

What it is

A highly available design keeps working when a component fails. In AWS the first building block is the Availability Zone (AZ): one or more data centers in a Region with separate power and networking. Placing resources in at least two AZs means one failure does not stop the service.

Elastic Load Balancing (ELB) spreads incoming traffic across targets in several AZs and stops sending traffic to targets that fail health checks.

UsersinternetLoad balancerspans two AZsTargets AZ ahealthyLoad balancerspans two AZsTargets AZ bhealthy

How it works

Choosing a load balancer

TypeLayer and protocolsChoose it when
Application Load Balancer (ALB)Layer 7, HTTP, HTTPS, gRPC, WebSocketPath or host based routing, microservices, containers, Lambda targets
Network Load Balancer (NLB)Layer 4, TCP, UDP, TLSVery high performance, static IP addresses per AZ, source IP preservation
Gateway Load Balancer (GWLB)Layer 3 gateway with GENEVE encapsulationRouting traffic through third party firewalls and inspection appliances
Classic Load BalancerLayers 4 and 7Legacy only, avoid for new designs

An ALB can route by URL path, host name, header or query string, and can authenticate users. An NLB can have an Elastic IP address in each AZ, which helps when clients must allow list fixed addresses. Targets can be instances, IP addresses and, for an ALB, Lambda functions.

Health checks and draining

Each target group defines a health check, with a protocol, path, interval and thresholds for healthy and unhealthy. A target is used only while it passes.

Deregistration delay lets in flight requests finish before a target is removed. Sticky sessions send a client to the same target, but they weaken even spreading, so store session data outside the instance when you can.

Cross zone load balancing

With cross zone load balancing, each load balancer node sends traffic to targets in all enabled AZs. Without it, each node sends only to targets in its own zone, so uneven target counts give uneven load. For an ALB it is always on at the load balancer level, and for an NLB it is off by default and can be turned on.

Subnets and placement

Create at least one subnet per AZ and enable those subnets on the load balancer. Put the load balancer in public subnets if it faces the internet, or in private subnets for an internal one. Targets usually sit in private subnets.

# AWS CLI: register a health check path on a target group
aws elbv2 modify-target-group \
  --target-group-arn arn:aws:elasticloadbalancing:us-east-1:111122223333:targetgroup/web/abc123 \
  --health-check-path /health

Design patterns for AZ failure

  • Run Auto Scaling groups in two or more AZs, with enough spare capacity that the remaining zones can carry the load.
  • Use Multi AZ for databases, covered on the next page.
  • Use EFS or S3 for shared data, since both store data across AZs (except the One Zone classes).
  • Keep session and state outside the instances.
  • Use one NAT gateway per AZ, so private subnets keep their internet path if a zone fails.

Securing the pair

Allow the load balancer's security group as the source in the target security group, so only the load balancer can reach the instances. TLS certificates for HTTPS listeners come from AWS Certificate Manager (ACM), and the load balancer can end TLS on behalf of the targets.

Exam tip

If the question mentions path based routing or host based routing, choose an ALB. If it mentions static IPs, TCP or UDP, or very high throughput, choose an NLB.

What to remember for the exam

  • An AZ is an isolated location inside a Region, and a highly available design uses at least two.
  • ALB is Layer 7 with content based routing, and NLB is Layer 4 with static IPs and low latency.
  • GWLB inserts third party virtual appliances into the traffic path.
  • Health checks are defined on the target group, and failing targets stop receiving traffic.
  • Deregistration delay lets in flight requests complete.
  • ALB cross zone balancing is on at the load balancer level, and NLB is off by default.
  • Place one NAT gateway in each AZ for independence.
  • Load balancers spread across AZs only for the subnets you enable on them.
  • Use the load balancer's security group as the source in the target's security group.

Common mistakes

Enabling only one subnet on the load balancer. The load balancer then cannot use targets in other zones.

Choosing an NLB for path routing. NLB works at Layer 4 and does not read URLs.

A health check path that needs a login. The target returns an error and is marked unhealthy.

Sharing one NAT gateway across zones. If that zone fails, private subnets in other zones lose internet access too.

Using sticky sessions as the state solution. If the target dies, the session is lost.

Watch out

A load balancer only adds resilience if the targets are in more than one AZ. Two targets in the same AZ still fail together.

Check yourself

Quick checks.

  • Which load balancer routes by URL path?

    The Application Load Balancer, which works at Layer 7.

  • A partner must allow list a fixed IP for your service. Which load balancer fits?

    A Network Load Balancer, which supports a static or Elastic IP address per AZ.

  • Why use one NAT gateway per AZ?

    A zone failure then does not remove the internet path for private subnets in the other zones.

Topic 2 of 5 in Reliability and Continuity

Test yourself on Reliability and Continuity

The full AWS SOA-C03 question bank has 850 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by AWS. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.