CHAPTER 03Part I · Fennel, year 2

Many containers, many machines: the orchestration problem

A year on, Fennel runs four services in containers across about eight machines, and Sam keeps a spreadsheet of what runs where. One week of Sam’s job shows the work that containers leave over, what that work costs a manager, and the name for software that does it instead.

Read
17 MIN
For
TECHNICAL MANAGERS
Chapter
03 / 15
Checks
09

§ 01 Year 2: eight machines and a spreadsheet

Cast

Sam
Founding engineer. Built Fennel’s first server and is on call for everything.
Jordan
Co-founder, now managing the engineers: that’s you, in this story.
Morgan
Co-founder. Runs the money.
Riley
Engineer since Year 1.
I didn’t read the last chapter. What happened?
  • In Chapter 1, Fennel ran on one server that Sam had built by hand. When its disk filled up during a Friday dinner rush, the site was down for two hours. Rebuilding the server from Sam’s notes then failed, because things had been added to it by hand and never written down.
  • In Chapter 2, Fennel started packing each piece of its software, with everything it needs to run, into an image.
  • A running copy of an image is a container. Many containers can share one machine.
  • Containers run on a machine. Chapter 2 ended on a question: what happens to them when that machine dies? The check below asks it.
RETRIEVECheck 01 / 09

Last chapter ended on a question. A year later, Fennel runs its containers on eight machines. At 3 a.m. one of those machines dies for good. What happens to the containers that were running on it?

It’s Year 2. Fennel’s app used to be one piece of software. It’s now four services, separate parts that each do one job: storefront (the site and app customers use), orders, payments and dispatch (which assigns drivers). Each service runs as one or more copies, and each copy is a container started from that service’s image. Fennel pays for about eight rented machines to run them on. Sam keeps a spreadsheet that says which container runs on which machine.

Jordan doesn’t see containers or machines. Jordan sees four things:

  • Sam has been woken by a page at 3 a.m. more than once this month.
  • Release days start with a message from Sam in the team chat: “Nobody deploy anything, I’m updating storefront.”
  • The last time anyone needed the spreadsheet in a hurry, it was wrong.
  • Morgan, reading the bill, asks why Fennel pays for eight machines when half of them look mostly idle.

Here is one week of Sam’s job, step by step.

§ 02 One week of Sam’s job

Monday: could four do it?

  1. What’s a unit of room?

    Real machines run out of memory and of processor time separately. The drawing in this section folds the two into one number to keep it simple. Chapter 5 counts them properly.

Saturday night

  1. APPLYCheck 02 / 09

    Machine 03 is gone, and orders needs 3 units of room. Of the three machines still running, where would you put it now?

  2. Answer the question above to see what happens

    What about the orders customers had already placed?

    Chapter 2 showed that the data a container writes, such as orders, is kept outside the container. Where Fennel keeps that data, and how it’s protected when a machine dies, is Chapter 10.

    PREDICTCheck 03 / 09

    orders is running again, on machine 04. Can customers place orders now?

  3. Answer the question above to see what happens

  4. Answer the question above to see what happens

Tuesday’s release

  1. PREDICTCheck 04 / 09

    There’s room for only one extra storefront copy. Which order of steps keeps the site up while all three copies become v13?

  2. Answer the question above to see what happens

  3. Answer the question above to see what happens

  4. Answer the question above to see what happens

EXPLAINCheck 05 / 09 · think, then reveal

Here’s everything Sam did between Monday and Tuesday. How many different kinds of job are in this list, and what would you call each one? Settle on your answer, then show it.

  1. Found a machine with room for each of nine containers.
  2. Wrote each one’s machine into the spreadsheet and into the settings of the services that call it.
  3. Restarted the crashed dispatch copy where it was.
  4. Started orders and dispatch on other machines after machine 03 died.
  5. Passed orders’ new address to storefront.
  6. Swapped storefront’s three copies to v13, one at a time.
  7. Left three storefront copies running all week, sized for Friday’s dinner rush.

§ 03 What the jobs cost

Each of the six jobs in Sam’s week shows up somewhere Jordan can see it.

Fig. 01The jobs, from the manager’s chair
JobWhat a manager sees
placingMachines kept half-empty “to be safe”, plus whole spare machines that sit empty, because moving things later by hand is slow and risky: idle spend.
restartingSomeone has to notice a crash and act, at any hour: pages.
replacingA dead machine takes its containers down with it until someone starts them elsewhere: 3 a.m. pages, outages, on-call burnout.
connecting“It’s running, but nothing can reach it” after a move, until someone tells its callers where it went; and a spreadsheet that falls behind.
updatingRelease days run by hand from the team chat (“Nobody deploy anything”): slow, risky releases.
scalingPaying all week for Friday’s peak, or scrambling during it.
The spreadsheetNot a job of its own: the hand-kept record of all six, always a little behind, like Sam’s server notes in Chapter 1.
Fig. 01Each job Sam did by hand shows up on a manager’s desk.

First, Morgan’s question: why do half of Fennel’s machines look mostly idle? When people place containers by hand, they play it safe. Moving a container later is slow and risky, so they leave free room on every machine and keep spare machines standing by. Some of that room is worth having: on Saturday night, the free room on machine 04 is where orders went. How much spare room is right is a question for Chapter 5. Still, idle machines are an old problem. One industry estimate, from data centres where each app had a server to itself, put the average server at only 12 to 18% busy.

Where does the 12–18% come from?

It’s a 2014 estimate by the Natural Resources Defense Council (NRDC), quoted by the US Environmental Protection Agency’s ENERGY STAR programme. It describes US corporate data centres running one app per server. It isn’t a measurement of machines running containers, or of Fennel.

Then there are the people doing the work. Google’s site reliability engineers have a name for manual, repetitive operations work that could be automated: toil. In their experience, toil grows in step with the service it supports, and too much of it burns people out, so they aim to keep it under half of each engineer’s time. Almost everything Sam did between Monday and Tuesday was toil.

And then there’s the spreadsheet. It’s Sam’s server notes from Chapter 1 again: a record kept by hand, of a system that changes every time something fails. A record like that falls behind, and on Saturday night this one did. It still says orders is on machine 03.

What if the record were the thing the machines act on, instead of a note about them? Hold that thought for the next chapter.

APPLYCheck 06 / 09

Next month Fennel adds a fifth service, catalog, with two copies. Nothing else changes, and Sam still does every job by hand. What happens to the work in Sam’s week?

§ 04 Software that does the jobs

What would help Sam isn’t a faster Sam. It’s software that does the six jobs in Fig. 01 by itself.

Doing those jobs automatically, for as long as the containers run, is called orchestration, and software that does it is an orchestrator. An orchestrator doesn’t only act when someone releases a new version. At 3 a.m., when a machine dies, it starts the lost containers on other machines and passes on their new addresses.

New term · 01 / 03

orchestration · orchestrator

Doing the six jobs automatically, all the time, for as long as the containers run; and the software that does it.

You met it in §02: Sam’s week.

You give an orchestrator a group of machines, physical or virtual, and tell it how big each container is. It fits the containers onto the machines itself. That group of machines, treated as one pool of room, is a cluster. The four machines Sam used in §02 would make a small one.

New term · 02 / 03

cluster

A group of machines an orchestrator treats as one pool of room for containers.

You met it in §02: the four machines.

Both definitions say what an orchestrator does, not how it does it. How it manages all this with nobody at a keyboard is the next chapter’s subject.

ANALOGYThe word comes from music. A conductor keeps dozens of players starting, stopping and changing together, so the orchestra sounds like one instrument.

WHERE THIS ANALOGY BREAKSA conductor is one person giving every cue from the front, and every player still uses their own judgement. In an orchestrator, no single part gives every cue: separate parts each watch for one kind of work and act on it. How that work is split up is the next chapter. And no part of it uses judgement: it follows rules, so it will keep restarting an app that is broken.

APPLYCheck 07 / 09

Riley says: “So an orchestrator is basically a smarter deploy script.” What does that leave out?

§ 05 Its name is Kubernetes

The orchestrator this course is about is Kubernetes. It’s the name the course has been heading for since Chapter 1.

New term · 03 / 03

Kubernetes

An orchestrator: software that does the six jobs across a cluster, all the time.

placing · restarting · replacing · connecting · updating · scaling

Kubernetes came out of Google. Google had run its own services in containers for years, on an internal system called Borg. It later built a second system, Omega, to try out new ideas, many of which went back into Borg. Just like Morgan at Fennel, Google cared about idle machines: one reason it built Borg was to let different kinds of work share the same machines, so that more of each machine gets used and costs come down.

You’ll hear that Kubernetes is Google’s Borg, released to the world. It isn’t. Kubernetes was Google’s third such system, built new with lessons from the first two, and open source from the start. Borg and Omega stayed inside Google.

Google published Kubernetes as open source in 2014. In 2015, at version 1.0, Google announced it would give Kubernetes to a newly formed foundation, the Cloud Native Computing Foundation, which is part of the Linux Foundation, so no single company owns it. By 2024, tens of thousands of people from thousands of companies had contributed to it.

Does Google run on Kubernetes?

Google’s own services ran on Borg, at least as of 2016, when the designers of Borg and Kubernetes described both in a paper. Kubernetes was built for developers outside Google, including the customers of Google’s cloud business.

Kubernetes isn’t the only orchestrator. Docker Swarm and Apache Mesos are two others, and Chapter 14 compares the options.

How Kubernetes does the six jobs with nobody at a keyboard is the next chapter. First, a name you’ll hear alongside it.

§ 06 Where Docker fits

You may already know the name Docker, and the last chapter on containers may have left you wondering how it fits in with Kubernetes. The two names come up together so often that they’re easy to mix up. So let’s introduce Docker properly, and see which job each one does.

PREDICTCheck 08 / 09

You’ll hear “Docker” and “Kubernetes” in the same breath. Before reading on: how do the two relate?

Fig. 02One machine, then the cluster

Docker: on one machine

builds the image; starts containers on the machine it’s run on

Machine · Riley’s laptop

Commands Riley types

docker build → makes the image storefront:v13

docker run → starts a container, on this laptop

storefront:v13 RUNNING
push
Registry
storefront:v13

an open standard: any orchestrator can run it

pull

An orchestrator (e.g. Kubernetes): across the cluster

decides which machines run each container, and keeps them running

Cluster
Machine · 01
storefront:v13payments
Machine · 02
storefront:v13dispatch
Machine · 03
ordersdispatch
Machine · 04
storefront:v13paymentsdispatch

placing · restarting · replacing · connecting · updating · scalingall the time

Fig. 02The image is the hand-off: the package Riley builds on one machine is the same package the cluster runs, whichever tool built it.

A container is a general idea, not a product: the containers in Chapter 2 could have been built and run with any of several tools. “Docker” is the best-known set of those tools, from the company of the same name, and the one that made containers popular. On Riley’s laptop, docker build makes the storefront:v13 image, and docker run starts a container from that image, on that laptop. Docker’s tools act on the machine they’re run on.

Riley then pushes the image to the registry. From there, an orchestrator such as Kubernetes decides which machines in the cluster run copies of it, starts those copies, and keeps doing the six jobs for them. In 2015, Docker and other container companies set up the Open Container Initiative, and Docker gave it its image format. That format is now an open standard, so Kubernetes runs an image whichever tool built it. That’s why Docker and Kubernetes aren’t competitors in the usual sense: most teams use Docker’s tools to build images, and an orchestrator to run them across their machines.

NOTEA laptop keeps the example simple. Real teams don’t ship images built on someone’s laptop: a shared build server builds and pushes them, so every image is made the same way from the team’s code.

Kubernetes was even announced at Docker’s own conference, DockerCon, in 2014.

You may have read “Kubernetes drops Docker”

Since 2022, Kubernetes no longer uses Docker’s own software to start containers on its machines; it uses other software that does the same job. Images built with Docker run exactly as before.

Didn’t Docker make an orchestrator too?

Yes: Docker Swarm, which did compete with Kubernetes at the orchestrator’s job. That’s the one place the two were rivals.

§ 07 The conversation

After another 3 a.m. page, Sam brings a proposal to the planning meeting.

“We should move to Kubernetes.”

Sam
APPLYCheck 09 / 09

Jordan asks Sam: “If we’d been on Kubernetes last Saturday, what would have been different?” Which answer holds up?

Moving still costs something: the platform, and the time to learn and run it. So the question for Jordan to bring to the planning meeting is: “Which of these jobs is hurting us most today, and is that worth the cost of the platform?” Chapter 14 comes back to the cost side.

That’s the end of Part I. Since its first server, Fennel has been catching up: the disk filled, so Sam wrote a clean-up job; a release broke in production, so the team moved to containers; a machine died, so Sam moved containers by hand at 3 a.m. Each fix came after the pain. Part II is about getting ahead of it: telling Kubernetes what Fennel wants running, and letting it keep things that way.

In short

  • Once many containers run on many machines, someone has to place them, restart and replace them, connect them, update them and scale them. By hand, that someone is Sam, at 3 a.m.
  • Each job lands on a manager’s desk: pages and burnout, idle machines, release days run from the team chat, and a spreadsheet that’s always behind.
  • An orchestrator does those jobs all the time, across a cluster of machines. Kubernetes is one, built from Google’s experience and now held by a foundation rather than one company. Docker’s tools build the images it runs.

Next: Fennel moves to Kubernetes, the same machine dies at 3 a.m., and nobody wakes up. The next chapter is how.

End of chapter 03

Next: Say what you want, not what to do

Chapter 04 · 23 min Say what you want, not what to do: desired state and the reconcile loop A year on, Fennel runs on managed Kubernetes. The same machine dies at 3 a.m., and this time nobody wakes up. How a written record of what Fennel wants, and many small loops that keep the cluster matching it, make that happen, and what those loops can’t do. Start chapter 04 →

Course

chapters
15
running
05
in review
02
pending
08
  1. Part IBefore Kubernetes03/03 running

    1. Ch 0117 minOne app, one serverRunning
    2. Ch 0218 min“Works on my machine”containersRunning
    3. Ch 0317 minMany containers, many machinesthe orchestration problemYou are here
  2. Part IIThe core model02/05 running · 02 in review

    1. Ch 0423 minSay what you want, not what to dodesired state and the reconcile loopRunning
    2. Ch 0525 minWho runs wherescheduling, resources and costRunning
    3. Ch 0627 minShipping without downtimerollouts and rollbacksUnder review
    4. Ch 0724 minFinding each otherservices and trafficUnder review
    5. Ch 08The Friday dinner rushautoscalingPending
  3. Part IIIThe hard parts00/04 running

    1. Ch 09Configuration and secretsPending
    2. Ch 10The database problemstatePending
    3. Ch 11Many teams, one clusternamespaces, permissions and quotasPending
    4. Ch 12Seeing insideincidents in a self-healing systemPending
  4. Part IVOwning it00/02 running

    1. Ch 13Teaching the cluster new tricksextensions and the ecosystemPending
    2. Ch 14What all this costsmanaged Kubernetes, platform teams and when not to use itPending
  5. CapstoneMixed practice00/01 running

    1. Ch 15Fennel’s hard weekPending
Fig. 00The whole course: 15 chapters in 4 parts and a capstone. Raised tiles are running; ones marked Under review are written and readable, still being checked; dashed ones are Pending, planned but not written yet.