โ Back to Elastic Load Balancing: ALB and NLB
๐ฌ Elastic Load Balancing: ALB and NLB: cheat sheet
๐จ The analogyAn airport arrivals hall: a guide reads tickets and walks people to gates, or a turnstile waves them through.
๐ The regular explanationAWS's managed load balancers. Listeners accept connections, rules pick a target group, and health checks keep traffic on healthy targets; the Application Load Balancer routes HTTP by path, host and header, while the Network Load Balancer forwards TCP, UDP and TLS with static IPs and the client's own address.
- A passenger walks into the arrivals hall through door 443 and hands over their ticket.
- The guide reads the ticket. The first line on the card that fits says "shop tickets go to gate A", so the guide walks the passenger to desk A1.
- Desk A1 gives its answer to the guide, and the guide brings it back out through the door to the passenger.
- The next ticket fits no line on the card, so the guide follows the last line, "everyone else to gate B", and picks a desk there.
- The ticket arrives sealed. The guide shows the official badge, so the passenger trusts them, and the guide opens the envelope.
- This ticket is for the shop, so the guide sends the passenger to the shop gate, and the answer comes back the same way.
- This ticket was issued by the airline to its own staff, so the card sends it to the staff gate.
- This ticket carries a "trial" stamp, so the guide sends it to the new gate being tried out.
- This one needs a gate with no desk. The guide rings the bell, a helper appears, deals with the passenger and goes away again.
- Each wing's turnstile has a fixed spot on the airport map. A passenger heads for the one in wing A.
- The turnstile doesn't read the ticket. It sends the passenger straight on to desk A, and the desk sees the passenger's own face.
- The desk's answer goes back through the same turnstile to the passenger.
- Wing A loses power. The map stops pointing passengers there, so they use the turnstile in wing B instead.
- The supervisor walks past every desk and asks "are you open?". All three answer yes.
- Desk 2's computer freezes. When the supervisor asks, there's no answer. One miss isn't enough to close it yet.
- A second miss, so desk 2 gets a "closed" sign. The guide now sends passengers only to desks 1 and 3.
- Desk 2 is fixed and starts answering. After five answers in a row the sign comes down and passengers arrive again.
- Passengers are split evenly between the two wings. Wing A's turnstile only uses its own desk, so desk A1 gets half of everyone.
- Wing B's turnstile shares its half between its three desks, so each of them gets only a sixth.
- Now the turnstiles may send passengers to desks in either wing. Every desk gets the same share, a quarter each.
- Before the swap, every passenger at this gate goes to the old desk.
- A new desk opens next to it. The supervisor checks it answers before the guide sends anyone there.
- The old desk gets a "no new passengers" sign. Newcomers go to the new desk, while the old one finishes the passenger already in front of it.
- The old desk has no one left, so it closes for good. Nobody was turned away during the swap.
- The partner's passenger heads for the turnstile's fixed spot, the one the partner wrote down once.
- The turnstile doesn't open the ticket. It sends the passenger straight on to the guide.
- The guide reads the ticket, sees it's for the shop, and walks the passenger to the shop gate.
- The answer goes back through the guide and the turnstile to the passenger.
๐งฉ Key questions
- You want shop tickets to go to one gate and staff tickets to another, sorted by what's written on each ticket. Who can do that?
- The guide, who reads every ticket and follows the card. The turnstile never opens the envelope, so it can't see what the ticket says. Only the guide can.
- A partner airline will only let passengers through from spots on the map it has written down once and for all. What do you give it?
- The turnstiles' fixed spots, one in each wing. Each turnstile has a fixed spot that never moves. The guide's spot shifts as the hall grows, and desks come and go.
- A desk's computer freezes and it stops answering the supervisor. What happens to passengers?
- After two missed answers it gets a closed sign and passengers go to the other desks. The supervisor keeps checking, and the desk reopens after five answers in a row.
- Wing A has one desk and wing B has three, and the turnstiles only use desks in their own wing. Which desk is busiest?
- Desk A1, which gets half of all passengers. Passengers are split evenly between the wings, not between desks. Letting turnstiles use any wing's desks fixes it.
- You swap an old desk for a new one. How do you avoid sending away passengers who are halfway through?
- Put up a no-new-passengers sign and let the old desk finish, within a time limit. The waiting time lets the people already at the desk finish, while everyone new goes to the new desk.