Lesson 05

Regions and the Arithmetic of Nines

Building block

An availability target is a number of minutes. Three nines allow about 44 minutes down a month, four nines about 4, and five nines about 5 minutes in a whole year. Each nine is a design decision before it is a promise: who notices the failure, who acts, and how fast.

Then comes the arithmetic. Parts in series multiply their availability down, and copies in parallel multiply their failures down, but only when the copies do not fail together. Regions are where that condition is bought, and the price is latency or lost writes.

Nines as Minutes

Each target is worth saying with what it rules out. At 99.9 percent, about 44 minutes a month leaves room for a person to be paged, look and act. At 99.99 percent, about 4 minutes a month is gone before a person has finished reading the page, so detection and failover are automatic. At 99.999 percent, about 5 minutes a year leaves room only for automation, and for changes that cannot reach the whole system at once.

Setting those targets and spending the error budget they leave is Observability Deep Dive's chapter on service level objectives. In the interview the target is an input, and the minutes are what you design against.

Three, four and five nines, as downtime
99.9 percentthree nines
43.8 minutes a month, 8.8 hours a year. A person can be paged, look and act.
99.99 percentfour nines
4.4 minutes a month, 53 minutes a year. Detection and failover are automatic.
99.999 percentfive nines
5.3 minutes a year. Automation only, and no change that reaches everything at once.

Series and Parallel

In series, a request that needs every part is up only when all of them are. While the downtimes are small, they roughly add. Three services at 99.9 percent each make about 99.7 percent. That is about 130 minutes down a month, a little over two hours.

Turned around, a target sets each part's share. Four nines allows about four minutes a month for the whole path. Split over three services, each one gets under a minute and a half.

In parallel, a pair is down only when both copies are. Two copies at 99.9 percent each, failing independently, are both down one time in a million. Everything turns on the word "independently", and the next section says what breaks it. Every optional dependency from the previous lesson is one part fewer in the series.

Series against parallel, every part at three nines
Three services in a roweach 99.9 percent
About 99.7 percent: the downtimes add, about 130 minutes a month.
Two copies side by sideeach 99.9 percent, independent
Both down one time in a million: 0.001 × 0.001, while nothing is shared.

Failure Domains

What copies share decides how independent they are: a host, a rack, a zone, a region. Two replicas in one zone go down with it. Zones are close: a round trip between zones of one region is 1 to 2 milliseconds, so a synchronous copy in a second zone costs little on each write.

Regions are far. A round trip from US east to US west is about 70 milliseconds, and to western Europe about 85. A synchronous copy in another region adds at least that round trip to every write, which is the latency half of PACELC from Chapter 4.

Some failure domains have no geography at all. One configuration push or one deploy reaches every region at once, which is why the cells and staged rollouts of the previous lesson belong in an availability answer.

RPO and RTO

A second region is bought for two numbers. The recovery point objective, the RPO, is how much recent data a disaster may lose. The recovery time objective, the RTO, is how long until the service is back.

With asynchronous replication, the RPO is the lag. Assume the copy runs 2 seconds behind, and the region takes 1,000 writes a second. Losing the region loses up to 2,000 writes that users were told had succeeded. An RPO of zero needs the synchronous copy from the previous section, with its round trip on every write.

Two regions, active-passive, with the replication lag as the RPO
Home region Second region Usersone home region Routingmoves on failover App serversserving Primarytakes the writes App serverswarm, idle Standby copy2 s behind writes async: lag = RPO failover readwriteasyncfailure

The RTO is detection, the decision to fail over, moving the traffic and capacity warm enough to take it, added together. At four nines every one of those steps is automatic. How one database engine replicates synchronously and fails over is PostgreSQL Deep Dive's chapter on replication, and leaders and followers in general open Chapter 4.

Active-Active and Where Data Lives

With more than one region serving, there are two designs. Either every region takes writes for every user, and concurrent writes conflict, which is the subject of Chapter 4's lesson on conflicts. Or each user has a home region that takes their writes, while the others serve reads and stand by.

Homing by user also answers residency. When a law or a contract keeps some users' data in one jurisdiction, their home region and its failover partner both sit inside it. Features that span every user, such as search and analytics, run on copies that are allowed to leave.

Capacity is the other price. Two active regions can each run at no more than half their capacity, because either one must carry the other's load. Three can each run at two thirds, because a lost region's third splits between the other two.

Active-Passive vs Active-Active

Active-passive serves from one region and keeps a second copied and ready. Use it when writes need one home and the target allows the time a failover takes; the idle region is the price.

Active-active serves from every region at once. Use it when users on several continents need nearby writes, or the RTO is shorter than a failover, and pay with user homing or conflict handling, plus headroom in every region.

How Interviewers Probe This

An availability answer starts with the target in minutes, works the arithmetic of the path, and ends on the region design and its price. You might say: "Four nines is about four minutes a month, so nobody gets paged in time. Failover has to be automatic."

It usually starts with "What availability are you designing for, and what does that take?" A good answer turns the target into minutes, multiplies along the critical path, and names what must be automatic.

Then "The whole region goes down. What do users see, and what did you lose?" A good answer gives the RTO from the failover steps, the RPO in writes from the lag, 2,000 of them in this lesson's numbers, and how traffic moves to the second region.

The last is often "Some customers need their data to stay in the EU." A good answer homes those users in a region inside it, keeps their failover inside it too, and names which global features run on copies allowed to leave.

Misconceptions
  • "Two copies at three nines make six nines." Only when they fail independently. Copies that share a zone, a deploy or a configuration are as available as what they share.
  • "A second region means no data loss." With asynchronous replication, a lost region takes the writes not yet copied, so the RPO is the lag.
  • "The system is as available as its weakest service." In series it is less available than any one of them, because their downtimes add.
  • "Five nines is a matter of better machines." Five minutes a year leaves no room for a person in the loop. It takes automatic failover, cells, and changes that never reach everything at once.
Why It Matters
  • Turn every availability target into minutes a month before designing for it, and say what that number rules out.
  • Multiply availability along the critical path, and take every optional dependency off it.
  • Put copies in separate failure domains, zones for synchronous copies and regions for disasters, and say what the copies still share.
  • State the RPO and RTO with what sets each: the replication lag, and the failover steps.
RelatedObservability Deep Dive SLOs and error budgetsPostgreSQL Deep Dive synchronous replication and failoverCAP and PACELC, Precisely the latency price of a far copy

Knowledge Check

A target moves from three nines to four. What happens to the downtime allowed each month?

  • It halves, from about 44 minutes to about 22
  • It drops from about 44 minutes to about 4 a month
  • It drops from about 4 hours to about 44 minutes
  • It drops from about 44 minutes to about 5 a year

A request needs three services in a row, each available 99.9 percent of the time. About how available is the request?

  • About 99.9 percent, the same as its weakest service
  • About 99.9999 percent, since three services back it
  • About 99.7 percent, roughly two hours down a month
  • About 99 percent, roughly seven hours down a month

Two copies at 99.9 percent each should both be down only one time in a million. When is that number wrong?

  • When the two copies are in regions far apart from each other
  • When the copies share a zone, a deploy or a configuration push
  • When the second copy is kept up to date asynchronously
  • When the two copies are watched by separate health checks

The second region's copy runs 2 seconds behind, and the region takes 1,000 writes a second. The region is lost. What is lost with it?

  • Nothing, because the second region holds a full copy of the data
  • About 2 writes, one for each second that the copy is behind
  • Up to about 2,000 writes that users were told had gone through
  • Every write since the last nightly backup was taken of the data

Every region must survive the loss of one other. How full can each region run with two active regions, and with three?

  • Two thirds with two regions, and three quarters with three
  • Fully in both cases, as traffic simply moves after a loss
  • At most half with two regions, and two thirds with three
  • At most half with two regions, and one third with three

You got correct