CHAPTER 01Part I · Fennel, year 0

One app, one server

On a Friday night Fennel’s site went down for two hours, and nobody had touched the code. What else lives on a server, and why a server built by hand is a risk to the business that runs on it.

Read
17 MIN
For
TECHNICAL MANAGERS
Chapter
01 / 15
Widgets
01
Checks
09

§ 01Friday, dinner rush

Fennel is a grocery-delivery startup with three people. Jordan and Morgan founded it, and Morgan handles the money. Sam is the only engineer, and built the one server the Fennel app runs on. In this chapter you’re in Jordan’s seat: you know roughly what a server and a deploy are, and you’ve never had to fix either.

It’s Friday evening, the dinner rush, the busiest hour of Fennel’s week. At 18:12 customers start seeing an error at checkout, and orders stop coming in. A few minutes later the first annoyed emails reach Jordan. Sam is at dinner across town and doesn’t pick up.

Here’s the strange part.

PREDICTCheck 01 / 09 · think, then reveal

Nobody has changed a line of Fennel’s code since Tuesday. So what could break checkout on Friday evening?

Settle on an answer in your head first.

Fig. 01Fennel’s Friday outage
    Fig. 01Deleting the logs took fifteen minutes. Most of the two hours went to reaching the one person who knew the server, and to that person finding the cause.

    The disk had filled with log files, the running diary the app and its web server keep of every request. They had been growing for months, because nobody had set anything up to clear out the old ones. With no space left, the database couldn’t save new orders. Nothing already stored was damaged, but nothing new could be written.

    Look at the last row, too. At 23:00 Sam set up a nightly job that deletes old logs, so the disk can’t fill up the same way again. It’s a good fix. Sam made it by hand, directly on the server, and didn’t write it down anywhere. That row comes back later.

    § 02What “the server” is

    The server is one computer that Fennel rents in a data centre. Like a laptop, it has a processor, memory and a disk. Unlike a laptop, it runs day and night, and customers reach it over the internet.

    Fig. 02One machine, one process
    Fennel’s server: one machine running the Fennel app as a process. A machine labelled Fennel’s server, rented. Inside it, the Fennel app is running, labelled process: the code, running. Beside it, the disk holds orders, logs and uploads. Customers’ requests arrive at the process from the left. From the code repo above, an arrow labelled deploy: copy new code, restart the app points into the machine. CODE REPO deploy: copy new code, restart the app MACHINE · FENNEL’S SERVER (RENTED) Fennel app RUNNING process: the code, running DISK orders, logs, uploads customers’ requests Fennel’s server: one machine running the Fennel app as a process. CODE REPO deploy: copy new code, restart the app MACHINE · FENNEL’S SERVER (RENTED) customers’ requests Fennel app RUNNING process: the code, running DISK orders, logs, uploads
    Fig. 02The app is the code running, as a process on one particular machine. Deploying means getting new code onto that machine.

    The orange block is the Fennel app while it runs. A running program is called a process: the code, loaded into the machine’s memory, answering customers’ requests and writing orders and log lines to the disk. On Friday the process kept running. It just couldn’t do its job, because the disk it writes to was full.

    When Sam ships a change, Sam copies the new code onto this machine and restarts the process. That copy-and-restart is a deploy, the arrow at the top of the figure.

    So far the app sounds like code plus a computer. But code can’t run on just any computer. At the very least it needs the language runtime it was written for, such as Python, and that runtime is installed on the machine, not shipped with the code. What else does it need? You’re about to find out by hand.

    § 03What’s on Sam’s server, and can you rebuild it?

    Below is Sam’s server as most people picture it: the code, running. First, work out what else is on it. Then try to build a second one using only Sam’s notes, and check whether it behaves like the first. It takes three or four minutes.

    § 04Why the notes fell behind

    Everything you found on Sam’s server besides the code is something the app needs in order to work. Most of them are dependencies: the language runtime, the libraries and tools the code calls, and the config that tells it where its database is and which keys to use. The app also relies on the data on the disk, its orders and customers, which changes every minute. Many of these things live on the machine, not in the code, and a different machine may not have them. That’s how identical code broke photo uploads on your new machine.

    Sam’s notes weren’t wrong when Sam wrote them. They described the server on the day it was set up. Then the photo tool went on in May, the email key in August, and the nightly log clean-up last Friday. Each was a sensible change, made by hand on the live server, and none of them reached the notes. Engineers call this drift (in full, configuration drift): changes to a system’s setup that go unrecorded. Every unrecorded change widens the gap between the notes and the server, so notes like Sam’s fall behind as a matter of course. Nobody has to be careless for it to happen.

    Then there’s the holiday-sale setting. Sam changed it during a sale and can’t say whether it still matters. With no second machine to try it on, the surest way to find out is to remove it and see what breaks, on the server that takes every order. Martin Fowler, a well-known writer on software design, describes exactly this state of an old, hand-tended server: “You’re not sure what parts of the configuration are important.” That’s where “don’t touch it” comes from. Nobody knows which settings the app relies on, so every change is a gamble.

    A server made unique by years of changes like these is a snowflake server. Fowler popularised the term in 2012: the result of all that hand-applied patching and tweaking is “a unique snowflake - good for a ski resort, bad for a data center.” Its first problem, he writes, is that it’s difficult to reproduce.

    ANALOGYRebuilding a server from its notes is like replacing a long-serving employee using only the job description they were hired with. The replacement does everything that’s written down. The duties that piled up over the years show up only when something doesn’t get done.

    WHERE THIS ANALOGY BREAKSA new hire notices gaps, asks around and uses judgment. A new machine does exactly what the notes say and fails without comment. And the old server can’t explain itself: even Sam doesn’t know which settings still matter.

    § 05If this box vanished tonight

    On Friday the server was sick, and Sam could nurse it back. Now suppose it’s gone.

    APPLYCheck 05 / 09

    Saturday, 2 a.m. The rented server’s hardware fails for good. The code is safe in the repo, and Sam has the notes. When is Fennel fully back to normal?

    So the length of an outage like this isn’t set by how fast someone can copy the code. It depends on how much is missing from the notes, and on whether the one person who knows the server is awake and reachable. Neither shows up in advance. The notes can’t list what they leave out, so the gaps surface as broken features. And the knowledge that fills them is mostly in Sam’s head, with some of it only on the machine that just died. That’s the practical meaning of Fowler’s warning about snowflakes: if the hardware fails, “it’s difficult to fire up another server to support the same functions.”

    ANALOGYManagers know the bus factor: how many people could disappear before a project stalls. Formally, it’s “a measurement of the risk resulting from information and capabilities not being shared among team members.” Fennel’s server has a bus factor of one: Sam.

    WHERE THIS ANALOGY BREAKSA bus factor is about what’s in people’s heads. Here part of the knowledge isn’t in anyone’s head. It exists only on the machine, and even Sam doesn’t know all of it.

    WHY RECOVERY TIMEFowler once joked about a “certification” for operations teams: someone walks into the data centre and attacks the production servers “with a baseball bat, a chainsaw, and a water pistol”, and the team is graded on “how long it would take for the operations team to get all the applications up and running again.” He suggests forgoing the baseball bats. The measure is the serious part: what counts is how long until you’re back when the server fails.

    § 06“Couldn’t we just…”

    After Friday, everyone reaches for a fix.

    PREDICTCheck 06 / 09

    After Friday, Morgan offers to pay for a much bigger server, with ten times the disk. Which of Friday’s problems does that solve?

    Bigger machines also run out. There’s a limit to how large a single machine can get, and near the top of the range the price climbs steeply. Fennel is nowhere near that ceiling, so for now the real objection is Friday’s: a bigger server is still one server, built by hand. Engineers call a machine like this a single point of failure: when something goes wrong with it, the whole site can go down with it.

    Sam’s idea uses a different kind of server. A virtual machine, or VM, is an isolated computer created in software, with its own processor, memory, disk and operating system. Several of them can run on one physical machine, and a new one can be created in minutes. The provider can also take a snapshot of the VM’s whole disk every night: an exact copy you can start again later.

    PREDICTCheck 07 / 09

    Sam suggests moving Fennel to a virtual machine at a cloud provider, with a snapshot of its disk taken every night. If that VM vanished tonight, what would getting back look like?

    Fig. 03Snapshot of a snowflake
    1. 1 · Thu 01:00Last night’s snapshot taken.

      Live VM
      • app code
      • runtime
      • libraries, tools
      • config file
      • 40 GB of old logs
      • holiday-sale setting UNKNOWN
      Snapshot
      • app code
      • runtime
      • libraries, tools
      • config file
      • 40 GB of old logs
      • holiday-sale setting UNKNOWN

      Exact copy, clutter included.

    2. 2 · Thu 15:00Sam fixes something by hand.

      Live VM
      • app code
      • runtime
      • libraries, tools
      • config file
      • new email setting hand-made, not in notes
      • 40 GB of old logs
      • holiday-sale setting UNKNOWN
      Snapshot
      • app code
      • runtime
      • libraries, tools
      • config file
      • 40 GB of old logs
      • holiday-sale setting UNKNOWN

      The snapshot doesn’t change.

    3. 3 · Thu 22:00The VM dies; restore last night’s snapshot.

      Restored VMRUNNING
      • app code
      • runtime
      • libraries, tools
      • config file
      • new email setting MISSING
      • 40 GB of old logs back
      • holiday-sale setting UNKNOWN

      Back in minutes. This afternoon’s fix is gone, and so are today’s orders.

    Fig. 03A snapshot gets you back fast. It also brings back the clutter, misses every hand-made change since it was taken, and tells you nothing about which settings matter.

    ANALOGYA snapshot is like photocopying Sam’s desk. You get a copy fast, coffee stains and wrong notes included, and you still don’t know which papers matter.

    WHERE THIS ANALOGY BREAKSA snapshot is an exact, working copy, so it really does get you back faster than a photocopy gets you a working desk. Its weaknesses lie elsewhere: it doesn’t help you understand or change the server, and it goes stale as soon as someone changes the live machine by hand.

    VMs give you more machines, faster. They don’t tell you what should be on them.

    § 07The conversation

    “We should keep a runbook for the server.”

    Sam

    A runbook is a written, step-by-step guide to setting up and repairing a system: think of Sam’s notes, kept current. It’s a good instinct. What matters is how Jordan answers.

    APPLYCheck 08 / 09

    The Monday after the outage, Sam says: “We should keep a runbook for the server.” What’s the most useful thing Jordan can say?

    APPLYCheck 09 / 09 · think, then reveal

    Sam answers your question. What answer should worry you, and what answer would reassure you? Think about it, then show the answer.

    In short

    • The app is the code plus everything it depends on, on one particular machine.
    • A hand-built server drifts away from its notes, and only a rebuild shows how far.
    • Bigger servers and VMs help, but neither tells you what should be on the machine.

    One question stays open. If the app is the code plus everything on the machine, how do you ship all of it? A year from now Fennel has six engineers, and that question comes up every day.

    End of chapter 01

    Next: “Works on my machine”

    Chapter 02 · 18 min “Works on my machine”: containers A year on, Fennel has a bug that happens in production and nowhere else. How packing the app with everything it needs moves that bug onto a laptop, and what it leaves unsolved. Start chapter 02 →

    Course

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

      1. Ch 0117 minOne app, one serverYou are here
      2. Ch 0218 min“Works on my machine”containersRunning
      3. Ch 0317 minMany containers, many machinesthe orchestration problemRunning
    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.