Elastic Load Balancing is the AWS service that distributes traffic, that is, the requests users send, across registered targets. A target is anything that can answer those requests: EC2 instances (virtual computers you rent from AWS), containers, IP addresses or Lambda functions, in one or more Availability Zones. For example, an online store with four instances puts a load balancer in front of them, and the load balancer sends each customer to one of the four.
The load balancer checks the health of each target and only sends traffic to the healthy ones, and it also scales its own capacity when traffic changes, without you having to do anything. For example, if one of the store's four instances stops responding, the load balancer sends customers only to the other three, and on the night of a big sale it handles more visits without the team making it bigger.
How does a request reach a target?
A load balancer is made up of nodes, one for each zone you enable in it, and each node is the part of the load balancer that runs in that zone. The load balancer has a name in DNS in the amazonaws.com domain, and that name answers with the IPs of the nodes. The TTL of that answer, which is how long the client can remember it before asking again, is 60 seconds, so the IPs can be changed quickly when the load balancer scales. For example, if the store's load balancer adds a new node, within a minute at most the customers are already getting its address.

Each client picks one of the IPs that DNS returns and connects to that node, and the node chooses a healthy target and sends the request to its private IP, the address that only works inside your network on AWS. That is why the targets can live in private subnets, without a public IP, the address anyone on the internet can reach. For example, nobody on the internet can reach the store's instances directly, but customers still buy because the load balancer passes each request on to them.
Listeners and target groups
When you configure a load balancer, you define two pieces that decide what traffic it receives and where it sends it:
- The listener, which is the process that listens for connections on a protocol, the language of the connection, and a port, for example HTTPS on 443. HTTPS is the protocol of secure websites.
- The target group, which is the group of targets together with its health check, the test that says whether each target is healthy. For example, the store has a target group with its four instances.
Enabled zones
AWS recommends enabling several zones on every load balancer, and the Application Load Balancer requires at least two. This decision also matters when you register targets, because targets in a zone that you didn't enable on the load balancer don't receive traffic. For example, if the store enables only zones A and B and launches an instance in zone C, that instance never gets customers.
How does the load balancer check the health of the targets?
The load balancer checks each target with the health check of its target group, which sends it a test request every so often and looks at whether it answers correctly. In an Application Load Balancer with targets of type instance or IP, the health check has these default values:
- The interval, which is one check every 30 seconds.
- The timeout, which is the longest it waits for the answer and is 5 seconds.
- The threshold to mark a target as unhealthy, which is 2 consecutive failures.
- The threshold for a target to become healthy again, which is 5 consecutive successes.
- The success code, which is 200, the number a website answers with when everything went fine.
With these values, a target that stops responding is taken out of traffic after two failed checks. For example, if one of the store's instances freezes, the load balancer stops sending it customers in about a minute.
When a target is unhealthy, the load balancer stops sending it traffic, but it doesn't replace it. Replacing the instance is the job of Amazon EC2 Auto Scaling, the service that keeps the number of instances you ask for, and it only does it if the group has the Elastic Load Balancing health check turned on. For example, the store's frozen instance stays on and without customers until Auto Scaling, with that health check turned on, swaps it for a new one.
Which type of load balancer fits?

Elastic Load Balancing has four types of load balancer, which differ in the network layer they work at. Layers are levels used to describe a connection, from the address it goes to (layer 3) up to what the web page asks for (layer 7). The higher the layer, the more the load balancer sees of each request:
- The Application Load Balancer (ALB), which works at layer 7, the application layer, where it opens the HTTP or HTTPS request, the protocol of websites, and decides based on what it contains. For example, it can see that a customer asked for the payments page and send them to the payments service.
- The Network Load Balancer (NLB), which works at layer 4, where it sees the protocol, the IPs and the ports, and which handles TCP, UDP, TLS and QUIC, protocols that move data without looking at which page was requested. For example, an online game that sends data over UDP uses an NLB.
- The Gateway Load Balancer (GWLB), which works at layer 3, the network layer, and which is used to pass all traffic through virtual appliances, which are programs that inspect traffic, such as firewalls or intrusion detection systems, and to scale them with demand. For example, a bank that wants to inspect everything coming into its network passes it through firewalls behind a GWLB.
- The Classic Load Balancer, which is the previous generation and from which AWS recommends migrating to a current one.
The differences between the ALB and the NLB are the ones that show up most in the questions. ALB rules can look at the domain (host), the path, the headers and other fields, so a single ALB serves several domains and microservices. For example, the store sends store.example.com/payments to its payments instances and store.example.com/catalog to the catalog ones with a single ALB.
The NLB, on the other hand, handles millions of requests per second according to the documentation, and it creates a network interface, the virtual network card traffic comes in through, with a static IP (one that doesn't change) in each zone, to which you can associate one Elastic IP per subnet. An Elastic IP is a fixed public IP that you reserve in your account. For example, if a bank only accepts connections from the store coming from addresses it wrote down on its list, the store uses an NLB with Elastic IPs so those addresses never change.
What is cross-zone load balancing?
Cross-zone load balancing is the option that decides whether each node distributes its requests across the targets in all zones or only across the ones in its own zone. This option matters because DNS distributes the clients across the nodes, so with two zones each node receives roughly half of the clients, no matter how many targets its zone has.

The example in the documentation has two targets in zone A and eight in zone B. With cross-zone turned on, each node distributes across the ten targets and each one receives 10% of the traffic. With cross-zone turned off, each node distributes only within its zone, so node A splits its 50% between two targets, 25% for each one, and node B splits its share among eight, 6.25% for each one. As a result, each target in zone A carries four times more load than one in zone B.
The default value of cross-zone depends on the type of load balancer. On the ALB it is always turned on at the load balancer level and can only be turned off in a target group. On the NLB and the GWLB, on the other hand, it comes turned off and you can turn it on whenever you want. For example, if the store uses an NLB with few instances in one zone and many in the other, the few will be overworked until it turns cross-zone on.
On the exam
Load balancing questions usually give a requirement and ask for the type of load balancer that meets it. Words such as "path", "domain", "header" or "HTTP" point to the ALB, while "UDP", "static IP", "Elastic IP", "allow list" or "millions of requests with very low latency" point to the NLB. For their part, "third-party appliance" or "transparent inspection of all traffic" point to the GWLB, and an answer that proposes a Classic Load Balancer for something new is ruled out, because AWS recommends migrating to a current load balancer. For example, if the question asks to send /payments and /catalog to different groups, the answer is an ALB with a path rule.
cloud path tip: if the scenario says that one zone carries much more load than another, check whether cross-zone load balancing is turned off and how many targets there are in each zone.
Full account and new experience account
Elastic Load Balancing is in the free plan of the new experience account, the simplified way to open an AWS account, in the project's Region (us-east-2 for Latin America). In both types of account, a load balancer is billed for each hour or partial hour that it is running, even if nobody uses it, plus the capacity units it consumes, which measure how much work it did. For example, if you create a load balancer to practice and leave it running all night with no visits, you still pay for those hours.
cloud path tip: delete the load balancer as soon as you finish practicing, because it is billed by the hour even if it receives no traffic.
Next