← Back to Index
Chapter 07 of 20

Elastic Load Balancing (ELB)

Domain 2 — Resilient Architectures (26%)
⚖️
Question 1Scenario

A company runs microservices with HTTP/HTTPS traffic. They need to route requests to different target groups based on the URL path — /api/* goes to the API service and /web/* goes to the web service. Which load balancer type supports this?

Explanation

ALB operates at Layer 7 and can inspect HTTP headers, paths, and hostnames. It supports listener rules for path-based routing (e.g., /api/* → Target Group 1) and host-based routing (api.example.com vs web.example.com). NLB operates at Layer 4 and does not inspect HTTP content. CLB is the legacy option with limited routing.

Question 2Scenario

A trading platform requires millions of requests per second with ultra-low latency, and the application needs to see the original client's source IP address without using HTTP headers. Which load balancer is MOST appropriate?

Explanation

NLB operates at Layer 4 (TCP/UDP/TLS). It can handle millions of requests per second with ultra-low latency. It preserves the client source IP by default (unlike ALB which uses X-Forwarded-For). NLB also supports static/Elastic IP addresses and is ideal for applications requiring IP whitelisting.

Question 3Knowledge

A company's ALB routes traffic to EC2 instances. They want users to always be sent to the same EC2 instance during their shopping session. Which ALB feature enables this?

Explanation

Sticky sessions (also called session affinity) work by inserting a cookie (AWSALB for ALB, AWSELB for CLB) in the response. Subsequent requests from the same client are routed to the same target for the duration of the sticky period. Note that stickiness can cause uneven load distribution.

Question 4Knowledge

What is the purpose of "Connection Draining" (also called "Deregistration Delay") in Elastic Load Balancing?

Explanation

When deregistering an instance (e.g., during a deployment or scale-in), ELB stops sending new requests to it but keeps existing connections open until they complete or the deregistration delay timeout expires (default 300 seconds, configurable 0–3600 seconds). This ensures graceful request completion without dropped connections.

Question 5Knowledge

An ALB distributes traffic to EC2 instances across 3 AZs — two AZs have 5 instances each and one AZ has only 1 instance. With cross-zone load balancing ENABLED, how is traffic distributed across the 11 instances?

Explanation

With cross-zone load balancing enabled (default for ALB, optional/extra cost for NLB), the load balancer distributes requests evenly across ALL registered targets in all enabled AZs, regardless of which AZ the request enters. Without cross-zone LB, each AZ node only routes to targets within that AZ, leading to uneven distribution when AZs have different instance counts.