VPC - An analogy about shared resources
Public subnets and Internet Gateway
Load balancing - one front door, many clerks
| Tier | Where | What |
|---|---|---|
| Web | hyf-week4-public-subnet-a (eu-central-1a) |
one hyf-web instance, public IP, hyf-web-sg allows 80 from 0.0.0.0/0 |
| Bastion | same public subnet | hyf-bastion |
| App | hyf-week4-private-subnet-a (eu-central-1a) |
hyf-app, outbound through the NAT Gateway |
| Data | hyf-week4-private-subnet-b (eu-central-1b) |
hyf-db, S3 through the gateway endpoint |
π Look at the first row again. Everything the internet sees is one machine, in one Availability Zone. Stop that instance, let its disk fill up, or lose eu-central-1a for an hour, and the site is gone β however carefully the security groups behind it were written.
Back to the building. Our shop has exactly one clerk, at one counter, in one district. Every visitor walks straight up to them. If they are ill, the shop is closed. If a hundred visitors show up at once, they queue out of the door.
π Today we hire a receptionist (the load balancer), open a second counter in another district (AZ B), and sign a contract with a staffing agency (the Auto Scaling group) that always keeps enough clerks on shift β and replaces any who don't show up.

Source: https://excalidraw.com/#json=lW1NxsB0_ITvXnJdrXueq,thy44V3mOVapT77b34cW6w
The rest of part 2 uses this mapping. Keep it in mind; every new AWS word below has a place in it.
| In the analogy | In AWS |
|---|---|
| ποΈ Reception desk at the building's front door β visitors never walk straight to a clerk | Application Load Balancer |
| πͺ The door the receptionist listens at (the front door, port 80) | Listener |
| π The receptionist's list of clerks they may send visitors to | Target group |
| π©Ί The receptionist checks on them every few seconds: "you OK?" | Health check |
| π€ Staffing agency contract: "always 2 clerks, never more than 4, spread across districts" | Auto Scaling group (min / desired / max) |
| π The job description the agency hires from | Launch template |
| π "If the queue gets long, call in more clerks" | Scaling policy (target tracking) |
| πͺͺ A badge on each clerk's door: "only the receptionist may send people to me" | hyf-web-sg allowing port 80 only from hyf-alb-sg |
When more visitors arrive than one clerk can handle, the shop needs to scale up: get more capacity. There are two directions to do it, and the difference matters a lot:
Horizontal scaling is what the cloud is built for, and it fixes both problems at once: capacity (more clerks) and availability (no single clerk the shop depends on). But it creates a new question β if there are four clerks, which one does a visitor go to? That is the load balancer's job.
<aside> π
Horizontal scaling only works if any server can answer any request. If a server keeps something important on its own disk or in its own memory β a logged-in user's session, an uploaded file β the next request may land on a different server that has never heard of it. Applications built to keep that kind of data elsewhere (a database, S3, a shared cache) are called stateless, and they are the ones that scale horizontally without surprises.
</aside>
A load balancer sits between your users and your servers, and does three things:
<aside> π
Always use the load balancer's DNS name (something like hyf-week4-alb-123456789.eu-central-1.elb.amazonaws.com), never the IP addresses it resolves to. AWS changes those IPs as it scales the load balancer itself β the name is the only thing that stays the same.
</aside>
Putting a load balancer in front of several servers buys you two things:
| Availability | Often called | Downtime allowed per month | Downtime allowed per year |
|---|---|---|---|
| 99 % | two nines | about 7 h 18 min | about 3.65 days |
| 99.9 % | three nines | about 43 min | about 8 h 46 min |
| 99.99 % | four nines | about 4 min 23 s | about 53 min |
| 99.999 % | five nines | about 26 s | about 5 min 16 s |
Each extra nine divides the downtime you are allowed by ten. A real example of the same idea: AWS promises 99.99 % monthly uptime for a load balancer spread over several Availability Zones, but only 99.9 % for one that lives in a single AZ (Elastic Load Balancing SLA). Multi-AZ is literally worth one extra nine in the contract.
β οΈ One trap to know about: availability multiplies along a chain. If the web tier, the app tier and the database are each 99.9 %, and a request needs all three, the whole site is about 99.9 % Γ 99.9 % Γ 99.9 % β 99.7 % β worse than any single part. That is why one single point of failure anywhere in the chain matters.
<aside> πΌ
The business tradeoff. Every extra nine costs roughly ten times more effort and money: more servers in more AZs (or even regions), automatic failover, engineers on call at night, and regular tests where you break things on purpose. Whether that is worth it depends on what an hour of downtime costs the business. An internal tool used during office hours can live with 99 %. A web shop loses sales every minute it is down. A payment or hospital system may need five nines. Engineers don't choose this number alone β it is agreed with the business, and written down as an SLA (a promise to customers, often with money back if it is broken) or an SLO (an internal target). Ask "what does an hour of downtime cost us?" before asking "how do we get another nine?".
</aside>
Before looking at how a load balancer routes requests, it helps to know what it can actually see of a request. That depends on the network layer it works at:
/api/* to these servers".AWS offers several types. You will see their names everywhere, so it is worth recognising them β but in this course we only use the ALB.
| Application Load Balancer (ALB) | Network Load Balancer (NLB) | Classic Load Balancer (CLB) | |
|---|---|---|---|
| Works at | Layer 7 β understands HTTP and HTTPS | Layer 4 β TCP, UDP, TLS: just packets and ports | Both, roughly |
| Can route on | URL path, host name, headers, query string, HTTP method, source IP | Port only | Very little |
| Typical use | Websites, web APIs, microservices | Extreme throughput, non-HTTP protocols, static IP addresses | Old setups only |
| In this course | β the one we build | π Recognise the name | π¦ Legacy β don't start new projects with it |
<aside> π‘οΈ
There is a fourth type: the Gateway Load Balancer (GWLB). It works even lower, at layer 3 (the network layer), and is used to pass traffic through a fleet of virtual firewalls or other network appliances. You won't need it in this course β just know the name exists.
</aside>
An AWS load balancer is built from four pieces, and a request passes through them in this order:
HTTP:80. Nothing reaches the load balancer except through a listener./api/* goes to one group, everything else to another".<aside> π
Targets don't have to be EC2 instances.
An ALB target group has one of three target types, chosen when you create it:
A Network Load Balancer can even use a whole ALB as its target. Listeners and rules work exactly the same whatever is behind the target group.
</aside>
<aside> π
The one fact to take away from this page: an Application Load Balancer always lives in at least two Availability Zones. AWS will not let you create one in a single AZ.
</aside>
An Application Load Balancer is not one machine. When you create it you pick one subnet per Availability Zone, and AWS runs a load balancer node in each of them. Its DNS name resolves to all of those nodes at once. If one AZ goes dark, DNS stops returning that node and the others carry on.
AWS makes this non-negotiable: an ALB must be placed in at least two AZs. You cannot build a single-AZ ALB even if you want to. That is why the next page starts by creating a second public subnet, in eu-central-1b. Each subnet you give the ALB must be in a different AZ, and needs at least a /27 CIDR block with at least 8 free IP addresses.
π By default an ALB also does cross-zone load balancing (always on for the load balancer itself; it can only be switched off per target group): a node in AZ A is happy to send a request to a server in AZ B, and the other way around. So traffic is spread evenly across servers, not just across AZs.