Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 01 · Portfolio Projects · Build It Yourself · with code: Go · about 20 min to read

Play it as a journeyTutor comes with a plan

S2 · Build a Load Balancer

S2 - Build a Load Balancer
S2 - Build a Load Balancer · Open board

One front door, a pool of identical servers behind it, and the two questions the door answers for every visitor: which one gets this request, and is it alive.

Before you start. You’ve met ports and connections in the networking track, and you can run a terminal command and write a little code, but you’ve never built a server. That’s fine: this is the first one. By the end you’ll have written about 130 lines of Go, watched it alternate between two servers, killed one on purpose, and watched traffic route around it with only one request ever failing.

Board: S2 - Build a Load Balancer Code: teaching/code/s2-loadbalancer/ (lb.go, main.go, passing lb_test.go)

Lesson 2 of 19 in Portfolio Projects · Free with an account

Keep reading. It's free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

No card, and chalk sends no email. Google sign-in only.

Start free with Google

In this lesson

  • 1994: one address stops being one computer
  • 1995: “about ten customers,” and the box that watched
  • The two jobs behind the door: which one, and is it alive
  • Round and round: who gets the next visitor
  • The corpse DNS couldn’t see
  • Get the code
  • The three moving parts, in Go
  • The three stages, each a commit
  • The architecture, drawn
  • One request, with a backend dying half-way
  • The whole build in code: 65 lines of node, then the Go
  • The arithmetic of a health check
  • Run it
  • Put it on GitHub

Terms it explains: backend, reverse proxy, round-robin, atomic counter, health check, Run it, Nginx "Load Balancing" guide, least-connections, sticky sessions, weighted, active vs passive.

Review Portfolio Projects