AlgoViz

The Facebook outage of 2021

medium 26 min

On 4 October 2021 a maintenance command took down every link of Facebook's backbone.

Video lesson · Chapter 1 of 5

The name that disappeared

0:00 / 3:40

The Facebook outage in 75 seconds

1:15Reel coming soon

Theory

Read or listen first. About 2 min.

What it is

On 4 October 2021 Facebook, Instagram, WhatsApp and the company's other products disappeared from the internet for hours. Nothing had been attacked and no data was lost. A command given during routine maintenance disconnected the company's backbone, the private network that joins its data centers.

Two more things turned that into a long outage. The company's name servers noticed that they could not reach a data center and stopped announcing their own addresses, so nobody could look up facebook.com. And the tools, and the out-of-band network, that engineers needed for the repair were down as well, so people had to travel to the buildings.

This page uses Facebook's two reports for what happened inside. Clock times come from Cloudflare, which watched from outside, because Facebook's reports give none.

Why it exists

It is one of the clearest public examples of a hidden shared dependency. Many copies of a service were running in many places, and all of them relied on one thing: the backbone.

It also shows that a sensible local rule can be harmful when every copy applies it at the same moment, and that a recovery plan must not need the thing that is broken. Those three ideas come up in almost every design discussion about availability.

A short history

  1. November 1983

    RFC 882 describes domain names: a distributed address book for the internet.

  2. June 1989

    RFC 1105 describes the Border Gateway Protocol, which networks use to tell each other what they can reach.

  3. July 1997

    RFC 2182 advises that the name servers of a zone should not all share the same location and the same path.

  4. December 2006

    RFC 4786 records good practice for anycast: one address announced from many places, with the announcement withdrawn when a place is unhealthy.

  5. 4 October 2021

    Facebook's backbone goes down. The company publishes a first report the same day and a detailed one on 5 October.

Words to know

Backbone
A company's own long-distance network between its buildings.
BGP
Border Gateway Protocol: how networks announce which addresses can be reached through them.
Prefix
A block of addresses that is announced or withdrawn as one.
Authoritative name server
The server that holds the real answer for a domain name.
SERVFAIL
The DNS reply a resolver gives when it could not get an answer.
Out-of-band network
A separate path to equipment, for when the normal network is down.
Blast radius
How much breaks when one thing breaks.

How it works

Step through the idea, or press Play.

Step 1 of 3

A command cuts the backbone. The audit tool that should stop it has a bug

Understand it

Start here

The lighthouse keeper

A keeper looks after a lighthouse on an island. One bridge leads there, and the board with the keys hangs on that same bridge. It is convenient every day, until the day the bridge is gone.

The bridge, the keys and the lamp
Bridge up, lamp on

The lighthouse was never damaged. Everything that led to it was.

Background

How a request normally arrives

A normal day

People ask a DNS resolver for a name. The resolver asks name servers in a smaller Facebook facility. People then send the request to the front door of that facility, which passes it over the backbone to apps and data in a data center.
Two kinds of building: smaller facilities close to people, and large data centers. The backbone joins them.

The report describes two kinds of building. Data centers hold millions of machines that store data and do the heavy work. Smaller facilities connect the backbone to the internet, and one of their jobs is to answer DNS questions. The backbone between them is tens of thousands of miles of fiber.

  • DNS finds the address

    A resolver asks Facebook's name servers which address belongs to a name. See how DNS works.

  • BGP finds the way

    Networks tell each other which addresses can be reached through them. If nobody announces an address, no packet can get there.

  • The backbone does the rest

    The smaller facility passes the request to a data center over private links, and the answer comes back the same way.

  • Health decides

    A name server that cannot talk to a data center stops announcing itself, so that healthy ones take over.

Opening the app on a normal day

Both halves need a route: one to the name server, one to the facility.

What happened

The timeline

4 October 2021, UTC, seen from outside

TimeEventReported by
no time givenA command during routine maintenance takes down all backbone connectionsFacebook
about 15:40A peak of routing changes from Facebook: routes are withdrawnCloudflare
about 15:50facebook.com stops resolving on 1.1.1.1Cloudflare
15:51Cloudflare opens an internal incident for SERVFAIL repliesCloudflare
15:58Cloudflare notices that routes to the name servers are goneCloudflare
no times givenEngineers travel to data centers, gain access, confirm the cause and restore the backboneFacebook
about 21:00New routing activity from Facebook's networkCloudflare
21:17That activity peaksCloudflare
about 21:20facebook.com resolves again on 1.1.1.1Cloudflare
21:28Facebook appears reconnected. Services take longer to return fullyCloudflare
Facebook's reports describe the order of events but no clock times. Minute-by-minute lists of the repair found elsewhere are not from the company, so they are left out.

How long the name was gone, and what that does to a yearly target

21:20−15:50=330 min99.99%:;0.0001×365×1440≈52.6 min a year33052.6≈6.3 years21{:}20 - 15{:}50 = 330\text{ min} \qquad 99.99\%:; 0.0001 \times 365 \times 1440 \approx 52.6\text{ min a year} \qquad \tfrac{330}{52.6} \approx 6.3\text{ years}
One event of this length uses more than six years of a 99.99% allowance. The inputs are Cloudflare's times for one domain name on one resolver; products came back later than the name.

Cause 1

The command and the guard

Engineers often take part of the backbone offline to repair a fiber, add capacity or update a router. During one such job, a command was issued to assess the availability of global backbone capacity. It unintentionally took down all the connections. The company has a tool that audits such commands and stops dangerous ones. A bug in that tool let this one pass.

Two layers, and both gave way

The guard is part of the system. If nobody tests that it says no, it may have stopped doing so long ago.

A safer way to run the same job

GuardQuestion it answersWould it have helped here?
Model the result firstIs every building still connected after this?Yes, if it does not share code with the audit tool
Limit the reachCan one command touch more than one region?Yes: the damage stops at one region
Go in wavesIs the first wave healthy after ten minutes?Yes, if waves are really separate
Automatic undoIf nobody confirms in time, put it back?Yes: it works even when the operator has lost access
Test the guardDoes it still refuse known bad commands?Yes: this finds the bug on a quiet day
This table is our advice, not a list from the report.

Cause 2

Why the names vanished

Everything is running, nothing can be reached

DNS resolvers have no route to the name servers in a smaller facility, which is running. The name servers get no answer over the backbone, whose links are all down. Internal tools and apps in the running data centers are cut off.
Dashed red arrows are paths that no longer work.

Name servers in the smaller facilities withdraw their BGP announcements when they cannot speak to the data centers, because that is a sign of an unhealthy network connection. When one facility is cut off, this rule is right: other facilities answer instead. This time the backbone was gone for all of them, so all of them withdrew.

One rule, every facility, the same minute

Three facilities stand for all of them.

Why many copies did not help

P(all down)=c+(1−c) pnp=0.01,;n=10,;c=0.0001:10−4+0.9999×10−20≈10−4P(\text{all down}) = c + (1-c)\,p^{n} \qquad p = 0.01,; n = 10,; c = 0.0001:\quad 10^{-4} + 0.9999 \times 10^{-20} \approx 10^{-4}
pp is the chance that one facility fails alone, nn the number of facilities and cc the chance of a cause they share. All three values are made up for the example. With any shared cause at all, more copies stop helping.

The rule is right when

  • One facility loses its links
  • Other facilities still reach a data center
  • Moving users away makes things better

The rule hurts when

  • Every facility fails its check at once
  • There is nobody left to take over
  • Withdrawing also removes the error page and the repair path

Cause 3

Why it took hours

  1. 1

    Normal access was down

    The networks of the data centers were down, so nobody could log in the usual way.

  2. 2

    Out-of-band access was down

    The second path, meant for this situation, did not work either.

  3. 3

    Internal tools were broken

    Losing DNS broke many of the tools used to investigate and resolve outages.

  4. 4

    Buildings are hard to enter

    They are designed with high physical and system security, so it took time to activate the secure access protocols.

  5. 5

    Routers are hard to change

    Even with physical access, hardware and routers are designed to be difficult to modify.

  6. 6

    Everything could not return at once

    Data centers reported power dips of tens of megawatts each. A sudden return could harm anything from electrical systems to caches.

The report says this trade is worth it: strong day-to-day protection in exchange for slower recovery from a rare event. That is a fair choice to make on purpose. The design question is whether the rescue path can be both secure and independent.

The tools need what is broken

A circle like this is easy to miss, because every day all parts are up. Draw it for your own tools, and look for the way out.

Effects

What others felt

WhoWhatSource
People and businessesFacebook's products unreachable; the company apologised to everyone who depends on themFacebook
User dataNo evidence that data was compromised; no malicious activityFacebook
StaffMany internal tools and systems affectedFacebook
DNS resolversResolvers were handling 30 times more queries than usualCloudflare
Other platformsMore DNS queries for Twitter, Signal and other servicesCloudflare
Estimates of lost money and shares of each region's users circulated in the press. No primary source gives them, so they are not repeated here.

The query flood is a thundering herd. Apps that do not accept an error keep asking, and people reload. A failed lookup costs the resolver more than a cached answer. Clients should back off and add jitter for DNS errors too.

Recovery

Coming back without falling over

Once the backbone was connected again, everything came back up with it, but services were not switched on all at once. The company had practised for years with storm drills: exercises that take a service, a data center or a whole region offline. No drill had ever removed the global backbone, and the report says they will look for ways to simulate that.

A staged return

Our picture of the idea. The report gives no step sizes.

Repair

The design we would draw next

A second way in

An on-call engineer uses a change gate for daily work, which changes the backbone in waves and the backbone carries traffic to a data center. For rescue, the engineer reaches a jump host and router consoles over separate links, which repair the backbone. Spare DNS and chat run at another provider.
Our suggestion. The green path has its own links, its own names and its own sign-in, and it is used in drills.

Six lessons and what to change

LessonChangeHow to check it
Rescue access must be independentSeparate links, power, names and sign-in for managementPull the main network in a drill and log in
One command must not reach everythingRegions as separate change domains, waves, automatic undoTry a bad change in a lab copy; see how far it goes
Doors must open without the networkLocal fallback for access to buildings and consolesRun the procedure with the network unplugged
Names need an independent copySome name servers on other networks, as RFC 2182 advisesResolve your domain with your own network filtered out
Talk on something elseA chat and phone bridge outside production, with printed numbersUse it once a month
Degrade instead of vanishingFail open when every copy fails its check; serve a static pageFail all health checks in a test and watch
Our advice, based on the causes above. The report itself promises stronger testing, drills and resilience.

Prefer

  • Management network with its own links
  • Several routes with safeguards
  • Name servers on more than one network
  • Dry run, waves, undo timer

Avoid

  • All tools on the network they repair
  • One change system for the whole world
  • All name servers behind one backbone
  • A guard that is never tested

Use it

Ask these about your own system

  1. 1

    If the network is gone, how do I log in?

    Write the steps. If any step needs DNS, single sign-on or chat from production, it fails.

  2. 2

    What do all copies share?

    Network, names, configuration, clock, sign-in, deployment. Shared things decide your real availability.

  3. 3

    What does each copy do when its check fails?

    Then ask what happens if every copy does that in the same second.

  4. 4

    How far can one command reach?

    If the answer is everywhere, split it.

  5. 5

    When did we last see the guard refuse something?

    A guard that never says no is untested.

  6. 6

    How do we turn everything back on?

    Know your step size for power, caches and connections.

Summary

The whole topic in one minute.

A maintenance command meant to assess backbone capacity took down all backbone links. An audit tool should have stopped it, but a bug let it through. Every smaller facility then lost contact with the data centers, judged itself unhealthy and withdrew the routes to its name servers. The servers were running, and nobody could find them.

Repair was slow because normal access, out-of-band access and many internal tools were down, and because buildings and routers are deliberately hard to get into. Power and traffic were then brought back in steps. The lessons: test the guard, limit how much one command can reach, beware of rules that every copy obeys at once, and keep a way in that shares nothing with production.

  • A maintenance command took down all backbone links; a bug in the audit tool let it through.
  • Name servers withdrew their routes as designed, all at once, so the names vanished while the servers ran.
  • Normal access, out-of-band access and many tools were down, so people went to the buildings.
  • Copies do not help against a cause they share.
  • Keep a tested rescue path that shares nothing, limit the reach of changes, and return in steps.

Sources