Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

System Design (High-Level Design)  Module 3 – Performance and reliability fundamentals

Availability maths: nines, series and parallel

Turn nines into allowed downtime, compute the availability of parts in series and in parallel, and see why shared causes break the redundancy you counted.

  • Beginner
  • 20 minutes
  • Examples run with Python 3.14.8, Pyodide 314.0.7, Node.js 24.21.0 and quickjs 0.32.0
  • By MySmartCoPilot
Free lesson, Pro answers: 20 minutes
Free: the whole lesson. With a pass: the model answers to its 2 interview questions.

What you will learn

  • Convert availability targets into allowed downtime over a day, a month and a year
  • Compute the availability of components in series and in parallel
  • Compare rarer failures with faster recovery, using MTBF and MTTR
  • Explain why independence assumptions often fail, and what removes shared causes

Before you start

What you’ll learn · Before you start

What you will learn

  • Convert availability targets into allowed downtime over a day, a month and a year
  • Compute the availability of components in series and in parallel
  • Compare rarer failures with faster recovery, using MTBF and MTTR
  • Explain why independence assumptions often fail, and what removes shared causes

Before you start

On this page

Availability is the share of time, or of requests, for which a service works. It is written in “nines”: 99.9% is three nines and allows 43.2 minutes of downtime in a 30-day month; 99.99% is four nines and allows 4.32 minutes. To estimate a design’s availability, combine its parts. Parts that are all needed, one after another, are in series, and their availabilities multiply, so the whole is weaker than its weakest part. Redundant parts of which any one is enough are in parallel, and the whole is down only when all of them are, so two 99% replicas give 99.99%. Both formulas assume that parts fail independently, and real failures often share a cause. Each step below is worked through with numbers.

Each nine divides the allowed downtime by ten

A target means little until it is turned into minutes, and the period it is measured over matters as much as the number. This calculator turns targets into downtime for five periods, and a month’s outages back into a percentage; change the lists at the top and run it again:

Allowed downtime per period, and what a month of outages leaves Python · nines/nines.py
"""Availability targets as allowed downtime, and downtime as availability.

Edit TARGETS or OUTAGES and run it again. The year is 365.25 days and the quarter a quarter of it; the month is
30 days, the month most availability tables use. "Nines" is -log10(1 - availability): 99.9% is 3 nines.
"""

import math

TARGETS = [99.0, 99.5, 99.9, 99.95, 99.99, 99.999]  # percent
OUTAGES = [(1, 43.2), (2, 12.0), (3, 4.5)]  # (outages in a 30-day month, minutes each)

PERIODS = [("day", 1), ("week", 7), ("30-day month", 30), ("quarter", 365.25 / 4), ("year", 365.25)]


def readable(minutes):
    """Minutes as the largest unit that keeps the number at 1 or more."""
    if minutes >= 60:
        return f"{minutes / 60:.2f} h"
    if minutes >= 1:
        return f"{minutes:.2f} min"
    return f"{minutes * 60:.1f} s"


print(f"{'target':>8}{'nines':>7}" + "".join(f"{name:>14}" for name, _ in PERIODS))
for target in TARGETS:
    down = 1 - target / 100
    nines = -math.log10(down)
    print(f"{target:>7}%{nines:>7.1f}" + "".join(f"{readable(days * 1440 * down):>14}" for _, days in PERIODS))

print("\nWhat a month of outages leaves")
for count, minutes in OUTAGES:
    down = count * minutes
    availability = 100 * (1 - down / (30 * 1440))
    outages = "1 outage" if count == 1 else f"{count} outages"
    print(f"{outages} of {minutes:g} min = {down:g} min down: {availability:.3f}% for the month")

Output

  target  nines           day          week  30-day month       quarter          year
   99.0%    2.0     14.40 min        1.68 h        7.20 h       21.92 h       87.66 h
   99.5%    2.3      7.20 min     50.40 min        3.60 h       10.96 h       43.83 h
   99.9%    3.0      1.44 min     10.08 min     43.20 min        2.19 h        8.77 h
  99.95%    3.3        43.2 s      5.04 min     21.60 min        1.10 h        4.38 h
  99.99%    4.0         8.6 s      1.01 min      4.32 min     13.15 min     52.60 min
 99.999%    5.0         0.9 s         6.0 s        25.9 s      1.31 min      5.26 min

What a month of outages leaves
1 outage of 43.2 min = 43.2 min down: 99.900% for the month
2 outages of 12 min = 24 min down: 99.944% for the month
3 outages of 4.5 min = 13.5 min down: 99.969% for the month

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 nines.py

Each extra nine divides the allowed downtime by ten. At 99.9%, a day allows 1.44 minutes and a year 8.77 hours (with a year of 365.25 days); at 99.99%, a year allows 52.6 minutes and a day only 8.6 seconds. The second block runs the other way: one 43.2-minute outage spends the whole of a month’s 99.9%, while three outages of 4.5 minutes leave 99.969%. The quality-attributes lesson showed what each downtime budget: The time a service may be unavailable over a stated period and still meet its availability target. At 99.9% a 30-day month allows 43.2 minutes, at 99.99% only 4.32. More in “Quality attributes and how to trade them off” means for how a team works; this lesson is about how the parts of a design add up to one number.

Availability can be counted in two ways. AWS’s availability whitepaper defines it by time, as uptime divided by uptime plus downtime. Google’s SRE book counts requests instead: the share of requests that succeed, because a service that runs in many places is almost never down everywhere at once, so minutes of total outage say little about what users met. A service that answers 2.5 million requests a day with a daily target of 99.99% may fail 250 of them. Counting requests also captures the partial outages that a time-based count misses, which the SLO lesson of this module builds on.

Key idea

A target is a downtime budget over a stated period: 99.9 % is 43.2 minutes in a 30-day month and 8.77 hours in a year, and each further nine divides it by ten.

Checkpoint

Check: Nines as downtime

  1. Question 1 of 2 How many minutes of downtime does a 99.99 % target allow in a year of 365.25 days? Answer to one decimal place.

    Type a number.

    A hint

    A year has 365.25 × 1,440 minutes; 0.01 % of them is the budget.

    Show the answer: Question 1 of 2

    Answer: 52.6 minutes (anything from 52.55 to 52.65 counts)

    365.25 × 1,440 = 525,960 minutes, and 0.01 % of them is 52.6 minutes, the figure in the program's table. A 30-day month at the same target allows 4.32 minutes.

  2. Question 2 of 2 A service answers 4,000,000 requests a day, and its daily target is 99.95 % of requests. How many requests may fail in a day?

    Type a number.

    Show the answer: Question 2 of 2

    Answer: 2000 requests

    The budget is 100 % − 99.95 % = 0.05 % of the requests: 0.0005 × 4,000,000 = 2,000. Counting requests, as the SRE book does, also counts the partial outages that a count of whole minutes misses.

Parts in series multiply

If a request needs every part of a chain, it succeeds only when all of them work at once. With independent parts, the availability of the chain is the product of theirs:

Aseries=A1×A2×⋯×AnA_{\text{series}} = A_1 \times A_2 \times \cdots \times A_n

Two 99.9% services in a row give 99.8001%: their unavailabilities, 0.1% each, roughly add up. That rule of thumb is the quickest check in a design round: a load balancer at 99.99%, an app tier at 99.95% and a database at 99.9% leave about 0.01 + 0.05 + 0.1 = 0.16% of failure, so the path is about 99.84%. Every extra hard dependency: A part that every request needs, so the service fails whenever it does. Hard dependencies are in series, and each one lowers the availability the whole service can reach. lowers the ceiling, which is why AWS’s whitepaper says that reducing dependencies improves availability, and that a workload’s dependencies should have goals at least as high as its own. The same paper adds that the product is only a rough estimate: published figures are targets, and dependencies often do better than their stated SLAs. Step along that three-part path, one part at a time:

Interactive · step by step Three parts in series, multiplied one at a time Step along the path of one request. Every part must work, so the path's availability is the product of the parts.
Three parts in series, multiplied one at a time, step 4 of 4. Showing A request, Load balancer, App tier, Database, The path so far (99.84 %). In focus: The path so far.A requestLoad balancer99.99 %App tier99.95 %Database99.9 %The path so far99.84 %

The drawing shows the whole scene; its 4 steps are listed below.

Every step as text
  1. The load balancer. The request needs the load balancer first. On its own the path is as available as that one part, 99.99 %.
  2. Times the app tier. It also needs the app tier, so multiply, 0.9999 × 0.9995 = 0.9994. The path is now weaker than either part.
  3. Times the database. And the database, 0.9994 × 0.999 = 0.9984. Three good parts make a path of 99.84 %, below the weakest of them.
  4. The quick check. For small numbers the unavailabilities add instead, 0.01 % + 0.05 % + 0.1 % = 0.16 %, which also gives 99.84 %. Each extra hard dependency adds its own share.

Checkpoint

Check: Parts in series

  1. Question 1 of 2 A request needs four services in a row, each 99.9 % available and failing independently. What is the path's availability, in percent to two decimal places?

    Type a number.

    A hint

    Multiply the four availabilities, or add the four unavailabilities as a quick check.

    Show the answer: Question 1 of 2

    Answer: 99.6 % (anything from 99.59 to 99.61 counts)

    0.999 to the power 4 ≈ 0.9960, so 99.60 %. The quick check gives the same: 4 × 0.1 % = 0.4 % of failure, about 173 minutes in a 30-day month.

  2. Question 2 of 2 A request needs a load balancer, an app tier and a database, one after another. Can the path be more available than its weakest part?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: No, because the path works only when every part works at once

    In series the availabilities multiply: 99.99 % × 99.95 % × 99.9 % gives 99.84 %, below the database's 99.9 %. Every hard dependency lowers the ceiling of the whole.

Redundant parts fail only when all of them fail

If any one of several parts is enough, the group fails only when all of them have failed at the same time. With independent parts, multiply the chances of failure instead:

Aparallel=1−(1−A1)(1−A2)⋯(1−An)A_{\text{parallel}} = 1 - (1 - A_1)(1 - A_2)\cdots(1 - A_n)

Two 99% replicas give 1 − 0.01 × 0.01 = 99.99%, and three give 99.9999%. Two things change this in practice. First, redundancy often has to cover capacity as well: if the peak needs two of three instances, the tier is up only while at least two are, which is a weaker condition than “any one”. Second, failing over takes time: a standby that needs a minute to take over adds a minute of downtime to every failure of the primary. This program puts both into one checkout path; its 14 versions, one per tab, printed exactly the lines shown below them:

One program · 14 languages Series, parallel and two of three, for one checkout path

Python 3.14 · main.py

from math import comb

MONTH = 30 * 24 * 60


def series(*parts: float) -> float:
    """All parts are needed: multiply."""
    result = 1.0
    for a in parts:
        result *= a
    return result


def parallel(*parts: float) -> float:
    """Any one part is enough: down only when all are down."""
    down = 1.0
    for a in parts:
        down *= 1 - a
    return 1 - down


def at_least(k: int, n: int, a: float) -> float:
    """At least k of n identical parts must be up."""
    return sum(comb(n, up) * a**up * (1 - a) ** (n - up) for up in range(k, n + 1))


def from_mtbf(mtbf: float, mttr: float) -> float:
    return mtbf / (mtbf + mttr)


def show(name: str, a: float) -> None:
    print(f"  {name:38}{a * 100:8.4f}%  down {(1 - a) * MONTH:4.1f} min a month")


print(f"any 2 of 3 replicas at 99%: {at_least(2, 3, 0.99) * 100:.4f}%")
lb, payments = 0.9999, 0.9995
app = at_least(2, 3, 0.995)
db = parallel(0.999, 0.999) - 2 / MONTH  # less 2 one-minute failovers
print("\nCheckout path")
show("load balancer", lb)
show("app tier (2 of 3)", app)
show("database pair", db)
show("payment provider", payments)
show("whole path", series(lb, app, db, payments))
print("\nRarer failures or faster recovery")
show("every 30 days, 60 min to recover", from_mtbf(720, 1))
show("every 60 days, 60 min to recover", from_mtbf(1440, 1))
show("every 30 days, 5 min to recover", from_mtbf(720, 5 / 60))

In Python: math.comb counts the ways to choose k of n, and *parts collects any number of availabilities into a tuple; a**up is the power.

Recorded with CPython 3.14.8 on macOS 26 arm64. It runs in your browser with Pyodide 314.0.7 (CPython 3.14.2). To run it yourself: python3 main.py

JavaScript Node 24 · main.mjs

const MONTH = 30 * 24 * 60;

// All parts are needed: multiply.
const series = (...parts) => parts.reduce((result, a) => result * a, 1);

// Any one part is enough: down only when all are down.
const parallel = (...parts) => 1 - parts.reduce((down, a) => down * (1 - a), 1);

function comb(n, k) {
  let ways = 1;
  for (let i = 1; i <= k; i++) ways = (ways * (n - k + i)) / i;
  return ways;
}

// At least k of n identical parts must be up.
function atLeast(k, n, a) {
  let sum = 0;
  for (let up = k; up <= n; up++) sum += comb(n, up) * a ** up * (1 - a) ** (n - up);
  return sum;
}

const fromMtbf = (mtbf, mttr) => mtbf / (mtbf + mttr);

function show(name, a) {
  const down = ((1 - a) * MONTH).toFixed(1).padStart(4);
  console.log(`  ${name.padEnd(38)}${(a * 100).toFixed(4).padStart(8)}%  down ${down} min a month`);
}

console.log(`any 2 of 3 replicas at 99%: ${(atLeast(2, 3, 0.99) * 100).toFixed(4)}%`);
const [lb, payments] = [0.9999, 0.9995];
const app = atLeast(2, 3, 0.995);
const db = parallel(0.999, 0.999) - 2 / MONTH; // less 2 one-minute failovers
console.log("\nCheckout path");
show("load balancer", lb);
show("app tier (2 of 3)", app);
show("database pair", db);
show("payment provider", payments);
show("whole path", series(lb, app, db, payments));
console.log("\nRarer failures or faster recovery");
show("every 30 days, 60 min to recover", fromMtbf(720, 1));
show("every 60 days, 60 min to recover", fromMtbf(1440, 1));
show("every 30 days, 5 min to recover", fromMtbf(720, 5 / 60));

In JavaScript: The rest parameter ...parts takes any number of availabilities, and reduce multiplies them; JavaScript has no binomial function, so comb is written out.

Recorded with Node.js 24.21.0 LTS (V8 13.6) on macOS 26 arm64. It runs in your browser with QuickJS (quickjs-emscripten 0.32.0). To run it yourself: node main.mjs

Java 25 LTS · Main.java

import java.util.Locale;

public class Main {
  static final double MONTH = 30 * 24 * 60;

  // All parts are needed: multiply.
  static double series(double... parts) {
    double result = 1;
    for (double a : parts) {
      result *= a;
    }
    return result;
  }

  // Any one part is enough: down only when all are down.
  static double parallel(double... parts) {
    double down = 1;
    for (double a : parts) {
      down *= 1 - a;
    }
    return 1 - down;
  }

  static long comb(int n, int k) {
    long ways = 1;
    for (int i = 1; i <= k; i++) {
      ways = ways * (n - k + i) / i;
    }
    return ways;
  }

  // At least k of n identical parts must be up.
  static double atLeast(int k, int n, double a) {
    double sum = 0;
    for (int up = k; up <= n; up++) {
      sum += comb(n, up) * Math.pow(a, up) * Math.pow(1 - a, n - up);
    }
    return sum;
  }

  static double fromMtbf(double mtbf, double mttr) {
    return mtbf / (mtbf + mttr);
  }

  static void show(String name, double a) {
    System.out.printf("  %-38s%8.4f%%  down %4.1f min a month%n", name, a * 100, (1 - a) * MONTH);
  }

  public static void main(String[] args) {
    Locale.setDefault(Locale.ROOT);
    System.out.printf("any 2 of 3 replicas at 99%%: %.4f%%%n", atLeast(2, 3, 0.99) * 100);
    double lb = 0.9999;
    double payments = 0.9995;
    double app = atLeast(2, 3, 0.995);
    double db = parallel(0.999, 0.999) - 2 / MONTH; // less 2 one-minute failovers
    System.out.println("\nCheckout path");
    show("load balancer", lb);
    show("app tier (2 of 3)", app);
    show("database pair", db);
    show("payment provider", payments);
    show("whole path", series(lb, app, db, payments));
    System.out.println("\nRarer failures or faster recovery");
    show("every 30 days, 60 min to recover", fromMtbf(720, 1));
    show("every 60 days, 60 min to recover", fromMtbf(1440, 1));
    show("every 30 days, 5 min to recover", fromMtbf(720, 5.0 / 60));
  }
}

In Java: The varargs double... parts take any number of availabilities, and main sets Locale.ROOT, so printf's decimal point cannot become a comma.

Recorded with OpenJDK 25.0.4.1 LTS (Eclipse Temurin) on macOS 26 arm64. It runs in your browser with a TeaVM 0.16.0 build in QuickJS (quickjs-emscripten 0.32.0). To run it yourself: java Main.java

C++23 · main.cpp

#include <cmath>
#include <initializer_list>
#include <print>
#include <string_view>

constexpr double month = 30 * 24 * 60;

// All parts are needed: multiply.
double series(std::initializer_list<double> parts) {
  double result = 1;
  for (const double a : parts) {
    result *= a;
  }
  return result;
}

// Any one part is enough: down only when all are down.
double parallel(std::initializer_list<double> parts) {
  double down = 1;
  for (const double a : parts) {
    down *= 1 - a;
  }
  return 1 - down;
}

long long comb(int n, int k) {
  long long ways = 1;
  for (int i = 1; i <= k; ++i) {
    ways = ways * (n - k + i) / i;
  }
  return ways;
}

// At least k of n identical parts must be up.
double at_least(int k, int n, double a) {
  double sum = 0;
  for (int up = k; up <= n; ++up) {
    sum += comb(n, up) * std::pow(a, up) * std::pow(1 - a, n - up);
  }
  return sum;
}

double from_mtbf(double mtbf, double mttr) { return mtbf / (mtbf + mttr); }

void show(std::string_view name, double a) {
  std::println("  {:<38}{:8.4f}%  down {:4.1f} min a month", name, a * 100,
               (1 - a) * month);
}

int main() {
  std::println("any 2 of 3 replicas at 99%: {:.4f}%",
               at_least(2, 3, 0.99) * 100);
  const double lb = 0.9999;
  const double payments = 0.9995;
  const double app = at_least(2, 3, 0.995);
  const double db =
      parallel({0.999, 0.999}) - 2 / month; // less 2 one-minute failovers
  std::println("\nCheckout path");
  show("load balancer", lb);
  show("app tier (2 of 3)", app);
  show("database pair", db);
  show("payment provider", payments);
  show("whole path", series({lb, app, db, payments}));
  std::println("\nRarer failures or faster recovery");
  show("every 30 days, 60 min to recover", from_mtbf(720, 1));
  show("every 60 days, 60 min to recover", from_mtbf(1440, 1));
  show("every 30 days, 5 min to recover", from_mtbf(720, 5.0 / 60));
}

In C++: An initializer_list lets series and parallel take any number of availabilities, and std::println writes the fixed decimals.

Recorded with Apple clang 21.0.0 (C++23) and GCC 16.2.0 on macOS 26 arm64. It runs in your browser with Clang in WebAssembly (YoWASP) 22.0.0-git20542-10. To run it yourself: clang++ -std=c++23 -O2 -Wall -Wextra -Werror -pedantic -fsanitize=address,undefined main.cpp -o main && ./main

C# 14 · .NET 10 · app.cs

using System.Globalization;

CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;

const double Month = 30 * 24 * 60;

Console.WriteLine($"any 2 of 3 replicas at 99%: {AtLeast(2, 3, 0.99) * 100:F4}%");
double lb = 0.9999, payments = 0.9995;
double app = AtLeast(2, 3, 0.995);
double db = Parallel(0.999, 0.999) - 2 / Month; // less 2 one-minute failovers
Console.WriteLine("\nCheckout path");
Show("load balancer", lb, Month);
Show("app tier (2 of 3)", app, Month);
Show("database pair", db, Month);
Show("payment provider", payments, Month);
Show("whole path", Series(lb, app, db, payments), Month);
Console.WriteLine("\nRarer failures or faster recovery");
Show("every 30 days, 60 min to recover", FromMtbf(720, 1), Month);
Show("every 60 days, 60 min to recover", FromMtbf(1440, 1), Month);
Show("every 30 days, 5 min to recover", FromMtbf(720, 5.0 / 60), Month);

// All parts are needed: multiply.
static double Series(params double[] parts) => parts.Aggregate(1.0, (result, a) => result * a);

// Any one part is enough: down only when all are down.
static double Parallel(params double[] parts) => 1 - parts.Aggregate(1.0, (d, a) => d * (1 - a));

static long Comb(int n, int k)
{
    long ways = 1;
    for (int i = 1; i <= k; i++)
    {
        ways = ways * (n - k + i) / i;
    }
    return ways;
}

// At least k of n identical parts must be up.
static double AtLeast(int k, int n, double a) => Enumerable.Range(k, n - k + 1)
    .Sum(up => Comb(n, up) * Math.Pow(a, up) * Math.Pow(1 - a, n - up));

static double FromMtbf(double mtbf, double mttr) => mtbf / (mtbf + mttr);

static void Show(string name, double a, double month) =>
    Console.WriteLine($"  {name,-38}{a * 100,8:F4}%  down {(1 - a) * month,4:F1} min a month");

In C#: params double[] takes any number of availabilities and Aggregate folds them; the month's minutes are a const passed to Show.

Recorded with C# 14 on .NET 10.0.12 (SDK 10.0.401) on macOS 26 arm64. It runs in your browser with the .NET runtime for WebAssembly 10.0.12. To run it yourself: dotnet run app.cs

C23 · main.c

#include <math.h>
#include <stddef.h>
#include <stdio.h>

constexpr double month = 30 * 24 * 60;

// All parts are needed: multiply.
static double series(const double parts[], size_t n) {
  double result = 1;
  for (size_t i = 0; i < n; i++) {
    result *= parts[i];
  }
  return result;
}

// Any one part is enough: down only when all are down.
static double parallel(const double parts[], size_t n) {
  double down = 1;
  for (size_t i = 0; i < n; i++) {
    down *= 1 - parts[i];
  }
  return 1 - down;
}

static long long comb(int n, int k) {
  long long ways = 1;
  for (int i = 1; i <= k; i++) {
    ways = ways * (n - k + i) / i;
  }
  return ways;
}

// At least k of n identical parts must be up.
static double at_least(int k, int n, double a) {
  double sum = 0;
  for (int up = k; up <= n; up++) {
    sum += (double)comb(n, up) * pow(a, up) * pow(1 - a, n - up);
  }
  return sum;
}

static double from_mtbf(double mtbf, double mttr) {
  return mtbf / (mtbf + mttr);
}

static void show(const char *name, double a) {
  printf("  %-38s%8.4f%%  down %4.1f min a month\n", name, a * 100,
         (1 - a) * month);
}

int main(void) {
  printf("any 2 of 3 replicas at 99%%: %.4f%%\n", at_least(2, 3, 0.99) * 100);
  const double lb = 0.9999;
  const double payments = 0.9995;
  const double app = at_least(2, 3, 0.995);
  // less 2 one-minute failovers
  const double db = parallel((double[]){0.999, 0.999}, 2) - 2 / month;
  puts("\nCheckout path");
  show("load balancer", lb);
  show("app tier (2 of 3)", app);
  show("database pair", db);
  show("payment provider", payments);
  show("whole path", series((double[]){lb, app, db, payments}, 4));
  puts("\nRarer failures or faster recovery");
  show("every 30 days, 60 min to recover", from_mtbf(720, 1));
  show("every 60 days, 60 min to recover", from_mtbf(1440, 1));
  show("every 30 days, 5 min to recover", from_mtbf(720, 5.0 / 60));
  return 0;
}

In C: A C function receives an array as a pointer and a count, so compound literals such as (double[]){0.999, 0.999} pass each list with its length.

Recorded with Apple clang 21.0.0 (C23) and GCC 16.2.0 on macOS 26 arm64. It runs in your browser with Clang in WebAssembly (YoWASP) 22.0.0-git20542-10. To run it yourself: clang -std=c23 -O2 -Wall -Wextra -Werror -pedantic -fsanitize=address,undefined main.c -o main && ./main

PHP 8.5 · main.php

<?php

declare(strict_types=1);

const MONTH = 30 * 24 * 60;

/** All parts are needed: multiply. */
function series(float ...$parts): float
{
    return array_reduce($parts, fn(float $result, float $a): float => $result * $a, 1.0);
}

/** Any one part is enough: down only when all are down. */
function parallel(float ...$parts): float
{
    return 1 - array_reduce($parts, fn(float $down, float $a): float => $down * (1 - $a), 1.0);
}

function comb(int $n, int $k): int
{
    $ways = 1;
    for ($i = 1; $i <= $k; $i++) {
        $ways = intdiv($ways * ($n - $k + $i), $i);
    }
    return $ways;
}

/** At least k of n identical parts must be up. */
function atLeast(int $k, int $n, float $a): float
{
    $sum = 0.0;
    for ($up = $k; $up <= $n; $up++) {
        $sum += comb($n, $up) * $a ** $up * (1 - $a) ** ($n - $up);
    }
    return $sum;
}

function fromMtbf(float $mtbf, float $mttr): float
{
    return $mtbf / ($mtbf + $mttr);
}

function show(string $name, float $a): void
{
    printf("  %-38s%8.4f%%  down %4.1f min a month\n", $name, $a * 100, (1 - $a) * MONTH);
}

printf("any 2 of 3 replicas at 99%%: %.4f%%\n", atLeast(2, 3, 0.99) * 100);
[$lb, $payments] = [0.9999, 0.9995];
$app = atLeast(2, 3, 0.995);
$db = parallel(0.999, 0.999) - 2 / MONTH; // less 2 one-minute failovers
echo "\nCheckout path\n";
show('load balancer', $lb);
show('app tier (2 of 3)', $app);
show('database pair', $db);
show('payment provider', $payments);
show('whole path', series($lb, $app, $db, $payments));
echo "\nRarer failures or faster recovery\n";
show('every 30 days, 60 min to recover', fromMtbf(720, 1));
show('every 60 days, 60 min to recover', fromMtbf(1440, 1));
show('every 30 days, 5 min to recover', fromMtbf(720, 5 / 60));

In PHP: The ** operator binds tighter than *, so the k-of-n term needs no brackets, and float ...$parts takes any number of availabilities.

Recorded with PHP 8.5.11 (CLI) on macOS 26 arm64. It runs in your browser with php-wasm 0.2.0 (PHP 8.5.2). To run it yourself: php main.php

Rust 1.99 · main.rs

const MONTH: f64 = 30.0 * 24.0 * 60.0;

/// All parts are needed: multiply.
fn series(parts: &[f64]) -> f64 {
    parts.iter().product()
}

/// Any one part is enough: down only when all are down.
fn parallel(parts: &[f64]) -> f64 {
    1.0 - parts.iter().map(|a| 1.0 - a).product::<f64>()
}

fn comb(n: u32, k: u32) -> u64 {
    (1..=u64::from(k)).fold(1, |ways, i| ways * (u64::from(n - k) + i) / i)
}

/// At least k of n identical parts must be up.
fn at_least(k: u32, n: u32, a: f64) -> f64 {
    (k..=n)
        .map(|up| comb(n, up) as f64 * a.powi(up as i32) * (1.0 - a).powi((n - up) as i32))
        .sum()
}

fn from_mtbf(mtbf: f64, mttr: f64) -> f64 {
    mtbf / (mtbf + mttr)
}

fn show(name: &str, a: f64) {
    println!(
        "  {name:38}{:8.4}%  down {:4.1} min a month",
        a * 100.0,
        (1.0 - a) * MONTH
    );
}

fn main() {
    println!(
        "any 2 of 3 replicas at 99%: {:.4}%",
        at_least(2, 3, 0.99) * 100.0
    );
    let (lb, payments) = (0.9999, 0.9995);
    let app = at_least(2, 3, 0.995);
    let db = parallel(&[0.999, 0.999]) - 2.0 / MONTH; // less 2 one-minute failovers
    println!("\nCheckout path");
    show("load balancer", lb);
    show("app tier (2 of 3)", app);
    show("database pair", db);
    show("payment provider", payments);
    show("whole path", series(&[lb, app, db, payments]));
    println!("\nRarer failures or faster recovery");
    show("every 30 days, 60 min to recover", from_mtbf(720.0, 1.0));
    show("every 60 days, 60 min to recover", from_mtbf(1440.0, 1.0));
    show(
        "every 30 days, 5 min to recover",
        from_mtbf(720.0, 5.0 / 60.0),
    );
}

In Rust: product() multiplies an iterator's values, and powi raises a float to a whole power, which is all the k-of-n term needs.

Recorded with rustc 1.99.0 (edition 2024) on macOS 26 arm64. It runs in your browser with a WebAssembly build on the WASI runner (browser_wasi_shim 0.4.2). To run it yourself: rustc --edition 2024 -O main.rs && ./main

TypeScript 6.0 · main.ts

const MONTH = 30 * 24 * 60;

// All parts are needed: multiply.
const series = (...parts: number[]): number => parts.reduce((result, a) => result * a, 1);

// Any one part is enough: down only when all are down.
const parallel = (...parts: number[]): number => 1 - parts.reduce((down, a) => down * (1 - a), 1);

function comb(n: number, k: number): number {
  let ways = 1;
  for (let i = 1; i <= k; i++) ways = (ways * (n - k + i)) / i;
  return ways;
}

// At least k of n identical parts must be up.
function atLeast(k: number, n: number, a: number): number {
  let sum = 0;
  for (let up = k; up <= n; up++) sum += comb(n, up) * a ** up * (1 - a) ** (n - up);
  return sum;
}

const fromMtbf = (mtbf: number, mttr: number): number => mtbf / (mtbf + mttr);

function show(name: string, a: number): void {
  const down = ((1 - a) * MONTH).toFixed(1).padStart(4);
  console.log(`  ${name.padEnd(38)}${(a * 100).toFixed(4).padStart(8)}%  down ${down} min a month`);
}

console.log(`any 2 of 3 replicas at 99%: ${(atLeast(2, 3, 0.99) * 100).toFixed(4)}%`);
const [lb, payments] = [0.9999, 0.9995];
const app = atLeast(2, 3, 0.995);
const db = parallel(0.999, 0.999) - 2 / MONTH; // less 2 one-minute failovers
console.log("\nCheckout path");
show("load balancer", lb);
show("app tier (2 of 3)", app);
show("database pair", db);
show("payment provider", payments);
show("whole path", series(lb, app, db, payments));
console.log("\nRarer failures or faster recovery");
show("every 30 days, 60 min to recover", fromMtbf(720, 1));
show("every 60 days, 60 min to recover", fromMtbf(1440, 1));
show("every 30 days, 5 min to recover", fromMtbf(720, 5 / 60));

In TypeScript: The rest parameter is typed number[]; the rest is the JavaScript program, on the same doubles.

Recorded with TypeScript 6.0.3 (strict), run by Node.js 24.21.0 on macOS 26 arm64. It runs in your browser with QuickJS (quickjs-emscripten 0.32.0) after Sucrase 3.35.1. To run it yourself: npx -p typescript@6.0.3 tsc --noEmit --strict main.ts && node main.ts

Go 1.27 · main.go

package main

import (
	"fmt"
	"math"
)

const month = 30 * 24 * 60

// series: all parts are needed, so multiply.
func series(parts ...float64) float64 {
	result := 1.0
	for _, a := range parts {
		result *= a
	}
	return result
}

// parallel: any one part is enough, so it is down only when all are.
func parallel(parts ...float64) float64 {
	down := 1.0
	for _, a := range parts {
		down *= 1 - a
	}
	return 1 - down
}

func comb(n, k int) int {
	ways := 1
	for i := 1; i <= k; i++ {
		ways = ways * (n - k + i) / i
	}
	return ways
}

// atLeast: at least k of n identical parts must be up.
func atLeast(k, n int, a float64) float64 {
	sum := 0.0
	for up := k; up <= n; up++ {
		sum += float64(comb(n, up)) * math.Pow(a, float64(up)) * math.Pow(1-a, float64(n-up))
	}
	return sum
}

func fromMtbf(mtbf, mttr float64) float64 {
	return mtbf / (mtbf + mttr)
}

func show(name string, a float64) {
	fmt.Printf("  %-38s%8.4f%%  down %4.1f min a month\n", name, a*100, (1-a)*month)
}

func main() {
	fmt.Printf("any 2 of 3 replicas at 99%%: %.4f%%\n", atLeast(2, 3, 0.99)*100)
	lb, payments := 0.9999, 0.9995
	app := atLeast(2, 3, 0.995)
	db := parallel(0.999, 0.999) - 2.0/month // less 2 one-minute failovers
	fmt.Println("\nCheckout path")
	show("load balancer", lb)
	show("app tier (2 of 3)", app)
	show("database pair", db)
	show("payment provider", payments)
	show("whole path", series(lb, app, db, payments))
	fmt.Println("\nRarer failures or faster recovery")
	show("every 30 days, 60 min to recover", fromMtbf(720, 1))
	show("every 60 days, 60 min to recover", fromMtbf(1440, 1))
	show("every 30 days, 5 min to recover", fromMtbf(720, 5.0/60))
}

In Go: Variadic parameters ...float64 take any number of availabilities, and math.Pow takes its exponent as a float64.

Recorded with Go 1.27.1 on macOS 26 arm64. It runs in your browser with the Go compiler in WebAssembly 1.27.1. To run it yourself: go run main.go

Swift 6.4 · main.swift

#if canImport(Darwin)
  import Darwin
#elseif canImport(WASILibc)
  import WASILibc
#endif

let month = 30.0 * 24 * 60

/// All parts are needed: multiply.
func series(_ parts: Double...) -> Double { parts.reduce(1, *) }

/// Any one part is enough: down only when all are down.
func parallel(_ parts: Double...) -> Double { 1 - parts.reduce(1) { $0 * (1 - $1) } }

func comb(_ n: Int, _ k: Int) -> Int {
  (0..<k).reduce(1) { ways, i in ways * (n - k + i + 1) / (i + 1) }
}

/// At least k of n identical parts must be up.
func atLeast(_ k: Int, _ n: Int, _ a: Double) -> Double {
  (k...n).reduce(0) { $0 + Double(comb(n, $1)) * pow(a, Double($1)) * pow(1 - a, Double(n - $1)) }
}

func fromMtbf(_ mtbf: Double, _ mttr: Double) -> Double { mtbf / (mtbf + mttr) }

/// Fixed decimals, since there is no String(format:) without Foundation.
func fixed(_ x: Double, _ digits: Int, width: Int) -> String {
  let scale = Int(pow(10, Double(digits)))
  let scaled = Int((x * Double(scale)).rounded())
  let fraction = String(scaled % scale)
  let text =
    "\(scaled / scale)." + String(repeating: "0", count: digits - fraction.count) + fraction
  return String(repeating: " ", count: max(0, width - text.count)) + text
}

func show(_ name: String, _ a: Double) {
  let label = name + String(repeating: " ", count: max(0, 38 - name.count))
  let down = fixed((1 - a) * month, 1, width: 4)
  print("  \(label)\(fixed(a * 100, 4, width: 8))%  down \(down) min a month")
}

print("any 2 of 3 replicas at 99%: \(fixed(atLeast(2, 3, 0.99) * 100, 4, width: 0))%")
let (lb, payments) = (0.9999, 0.9995)
let app = atLeast(2, 3, 0.995)
let db = parallel(0.999, 0.999) - 2 / month  // less 2 one-minute failovers
print("\nCheckout path")
show("load balancer", lb)
show("app tier (2 of 3)", app)
show("database pair", db)
show("payment provider", payments)
show("whole path", series(lb, app, db, payments))
print("\nRarer failures or faster recovery")
show("every 30 days, 60 min to recover", fromMtbf(720, 1))
show("every 60 days, 60 min to recover", fromMtbf(1440, 1))
show("every 30 days, 5 min to recover", fromMtbf(720, 5.0 / 60))

In Swift: pow comes from the platform's C library (Darwin on macOS, WASILibc in WebAssembly), and fixed writes the decimals by hand, since there is no String(format:) without Foundation.

Recorded with Apple Swift 6.4 on macOS 26 arm64. It runs in your browser with a WebAssembly build on the WASI runner (browser_wasi_shim 0.4.2). To run it yourself: swiftc -O main.swift -o main && ./main

Ruby 4.0 · main.rb

# frozen_string_literal: true

MONTH = 30 * 24 * 60

# All parts are needed: multiply.
def series(*parts)
  parts.reduce(1.0) { |result, part| result * part }
end

# Any one part is enough: down only when all are down.
def parallel(*parts)
  1 - parts.reduce(1.0) { |down, part| down * (1 - part) }
end

def comb(count, chosen)
  (1..chosen).reduce(1) { |ways, i| ways * (count - chosen + i) / i }
end

# At least k of n identical parts must be up.
def at_least(needed, count, share)
  (needed..count).sum { |up| comb(count, up) * (share**up) * ((1 - share)**(count - up)) }
end

def from_mtbf(mtbf, mttr)
  mtbf.fdiv(mtbf + mttr)
end

def show(name, share)
  puts format('  %<name>-38s%<pct>8.4f%%  down %<down>4.1f min a month',
              name: name, pct: share * 100, down: (1 - share) * MONTH)
end

puts format('any 2 of 3 replicas at 99%%: %.4f%%', at_least(2, 3, 0.99) * 100)
lb = 0.9999
payments = 0.9995
app = at_least(2, 3, 0.995)
db = parallel(0.999, 0.999) - 2.0 / MONTH # less 2 one-minute failovers
puts "\nCheckout path"
show('load balancer', lb)
show('app tier (2 of 3)', app)
show('database pair', db)
show('payment provider', payments)
show('whole path', series(lb, app, db, payments))
puts "\nRarer failures or faster recovery"
show('every 30 days, 60 min to recover', from_mtbf(720, 1))
show('every 60 days, 60 min to recover', from_mtbf(1440, 1))
show('every 30 days, 5 min to recover', from_mtbf(720, 5.0 / 60))

In Ruby: Integer#fdiv divides as floats, so 720.fdiv(721) needs no conversion, and sum adds the k-of-n terms.

Recorded with CRuby 4.0.7 on macOS 26 arm64. It runs in your browser with ruby.wasm 2.10.1 (Ruby 4.0.0). To run it yourself: ruby main.rb

Kotlin 2.4 · Main.kt

import kotlin.math.pow
import kotlin.math.roundToLong

const val MONTH = 30.0 * 24 * 60

// All parts are needed: multiply.
fun series(vararg parts: Double) = parts.fold(1.0) { result, a -> result * a }

// Any one part is enough: down only when all are down.
fun parallel(vararg parts: Double) = 1 - parts.fold(1.0) { down, a -> down * (1 - a) }

fun comb(
    n: Int,
    k: Int,
) = (1..k).fold(1L) { ways, i -> ways * (n - k + i) / i }

// At least k of n identical parts must be up.
fun atLeast(
    k: Int,
    n: Int,
    a: Double,
) = (k..n).sumOf { up -> comb(n, up) * a.pow(up) * (1 - a).pow(n - up) }

fun fromMtbf(
    mtbf: Double,
    mttr: Double,
) = mtbf / (mtbf + mttr)

// Fixed decimals, since the common standard library has no String.format.
fun fixed(
    x: Double,
    digits: Int,
): String {
    val scale = 10.0.pow(digits).toLong()
    val scaled = (x * scale).roundToLong()
    return "${scaled / scale}.${(scaled % scale).toString().padStart(digits, '0')}"
}

fun show(
    name: String,
    a: Double,
) {
    val down = fixed((1 - a) * MONTH, 1).padStart(4)
    println("  ${name.padEnd(38)}${fixed(a * 100, 4).padStart(8)}%  down $down min a month")
}

fun main() {
    println("any 2 of 3 replicas at 99%: ${fixed(atLeast(2, 3, 0.99) * 100, 4)}%")
    val (lb, payments) = 0.9999 to 0.9995
    val app = atLeast(2, 3, 0.995)
    val db = parallel(0.999, 0.999) - 2 / MONTH // less 2 one-minute failovers
    println("\nCheckout path")
    show("load balancer", lb)
    show("app tier (2 of 3)", app)
    show("database pair", db)
    show("payment provider", payments)
    show("whole path", series(lb, app, db, payments))
    println("\nRarer failures or faster recovery")
    show("every 30 days, 60 min to recover", fromMtbf(720.0, 1.0))
    show("every 60 days, 60 min to recover", fromMtbf(1440.0, 1.0))
    show("every 30 days, 5 min to recover", fromMtbf(720.0, 5.0 / 60))
}

In Kotlin: vararg collects the availabilities into a DoubleArray, and fixed writes the decimals, since the common standard library has no String.format.

Recorded with Kotlin 2.4.20 on Java 25.0.4.1 on macOS 26 arm64. It runs in your browser with a WebAssembly build on the WASI runner (browser_wasi_shim 0.4.2). To run it yourself: kotlinc Main.kt -include-runtime -d main.jar && java -jar main.jar

Dart 3.13 · main.dart

import 'dart:math';

const month = 30 * 24 * 60;

/// All parts are needed: multiply.
double series(List<double> parts) => parts.fold(1.0, (result, a) => result * a);

/// Any one part is enough: down only when all are down.
double parallel(List<double> parts) =>
    1 - parts.fold(1.0, (d, a) => d * (1 - a));

int comb(int n, int k) {
  var ways = 1;
  for (var i = 1; i <= k; i++) {
    ways = ways * (n - k + i) ~/ i;
  }
  return ways;
}

/// At least k of n identical parts must be up.
double atLeast(int k, int n, double a) {
  var sum = 0.0;
  for (var up = k; up <= n; up++) {
    sum += comb(n, up) * pow(a, up) * pow(1 - a, n - up);
  }
  return sum;
}

double fromMtbf(double mtbf, double mttr) => mtbf / (mtbf + mttr);

void show(String name, double a) {
  final down = ((1 - a) * month).toStringAsFixed(1).padLeft(4);
  print(
    '  ${name.padRight(38)}${(a * 100).toStringAsFixed(4).padLeft(8)}%  down $down min a month',
  );
}

void main() {
  print(
    'any 2 of 3 replicas at 99%: ${(atLeast(2, 3, 0.99) * 100).toStringAsFixed(4)}%',
  );
  const lb = 0.9999, payments = 0.9995;
  final app = atLeast(2, 3, 0.995);
  final db =
      parallel([0.999, 0.999]) - 2 / month; // less 2 one-minute failovers
  print('\nCheckout path');
  show('load balancer', lb);
  show('app tier (2 of 3)', app);
  show('database pair', db);
  show('payment provider', payments);
  show('whole path', series([lb, app, db, payments]));
  print('\nRarer failures or faster recovery');
  show('every 30 days, 60 min to recover', fromMtbf(720, 1));
  show('every 60 days, 60 min to recover', fromMtbf(1440, 1));
  show('every 30 days, 5 min to recover', fromMtbf(720, 5 / 60));
}

In Dart: pow from dart:math returns a num, which the double arithmetic around it accepts, and ~/ is integer division in comb.

Recorded with Dart 3.13.5 on macOS 26 arm64. It runs in your browser with a WebAssembly build by dart2wasm 3.13.5. To run it yourself: dart run main.dart

What every language printed

any 2 of 3 replicas at 99%: 99.9702%

Checkout path
  load balancer                          99.9900%  down  4.3 min a month
  app tier (2 of 3)                      99.9925%  down  3.2 min a month
  database pair                          99.9953%  down  2.0 min a month
  payment provider                       99.9500%  down 21.6 min a month
  whole path                             99.9278%  down 31.2 min a month

Rarer failures or faster recovery
  every 30 days, 60 min to recover       99.8613%  down 59.9 min a month
  every 60 days, 60 min to recover       99.9306%  down 30.0 min a month
  every 30 days, 5 min to recover        99.9884%  down  5.0 min a month
A checkout path in series: load balancer, an app tier of three instances, a database pair, and a payment provider.Load balancer99.99%App tier: any 2 of 3 instances99.9925%Database pair: either one99.9953% after failoversPayment provider99.95%App 199.5%App 299.5%App 399.5%Primary99.9%Standby99.9%

One checkout path: four parts in series, two of them redundant inside

Text description of the diagram

The diagram shows the parts a checkout request passes through, from top to bottom. The request needs every part, so the parts are in series.

  1. A load balancer, 99.99% available.
  2. An app tier of three instances, each 99.5% available. The peak needs any two of them, which makes the tier 99.9925% available.
  3. A database pair, a primary and a standby, each 99.9% available. Either one can serve, so the pair is down only when both are, plus about two minutes a month of failover gaps: 99.9953% in all.
  4. An outside payment provider, 99.95% available.

The whole path is about 99.928% available, and the payment provider alone accounts for about two thirds of its downtime. All the numbers are the assumptions and results of the checkout program above the diagram.

Two of three 99% instances give 99.9702%, against 99.9999% when any one would do. On the checkout path, the redundant app tier and database pair are down only 3.2 and 2.0 minutes a month, while the payment provider, a single outside dependency at 99.95%, accounts for 21.6 of the path’s 31.2 minutes. The path is 99.928% available, and more app instances would not change that: the next improvement has to come from the payment provider, for example a second provider to fail over to, or from not making the payment a hard dependency of every checkout.

AWS’s whitepaper makes the same point about spares from the other side: each spare costs as much as the original, and beyond about three spares for a part that is at least 99% available the extra availability is not worth it. It also warns about the unit of failure: ten instances in one Availability Zone are one failure if the zone goes, so the spare should be a second zone, or three zones of five instances each, which still leaves ten when one zone is lost.

Key idea

Redundancy multiplies the chances of failure, so two independent 99 % parts give 99.99 %; needing two of three, or waiting for a failover, gives less, and a single dependency left in series sets the ceiling.

Checkpoint

Check: Redundant parts in parallel

  1. Question 1 of 2 Three independent replicas are each 95 % available, and any one of them is enough. What is the group's availability, in percent to four decimal places?

    Type a number.

    A hint

    The group is down only when all three are down at once.

    Show the answer: Question 1 of 2

    Answer: 99.9875 % (anything from 99.9874 to 99.9876 counts)

    All three are down together with probability 0.05 × 0.05 × 0.05 = 0.000125, so the group is up 99.9875 % of the time, if their failures really are independent.

  2. Question 2 of 2 Three 99 % instances give 99.9999 % when any one is enough, but only 99.9702 % when the peak needs two of them. Why?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: With two needed, one failure leaves no spare, so a second failure at the same time takes the tier down

    Two of three is up when all three are (0.99 cubed) or exactly two are (3 × 0.99² × 0.01), 99.9702 % in all. Redundancy that must also carry the peak covers fewer failures than redundancy for its own sake.

Faster recovery buys more nines

Availability can also be written in mean times: a part that runs for its mean time between failures (MTBF): The average time a part runs between one failure and the next. With the mean time to recover, it gives the part's availability: MTBF divided by MTBF plus MTTR. (MTBF) and then takes its mean time to recover (MTTR): The average time from a failure until the part works again, detection included. Cutting it from 60 minutes to 5 took a monthly failure from 99.8613 % to 99.9884 %. (MTTR) is available

A=MTBFMTBF+MTTRA = \frac{\text{MTBF}}{\text{MTBF} + \text{MTTR}}

The last block of the program compares two ways to improve a service that fails once every 30 days and needs an hour to recover (99.8613%). Halving how often it fails gives 99.9306%. Recovering in 5 minutes instead of 60 gives 99.9884%, more than either, and often at a lower cost: automatic detection, automatic failover and a fast rollback are usually easier to build than a system that fails half as often. AWS’s whitepaper names the same three levers: fewer failures, faster detection, which is part of recovery, and faster repair. In minutes of a 30-day month, from the same block:

The same service Availability Down in a 30-day month
Fails every 30 days, recovers in 60 minutes 99.8613 % 59.9 minutes
Fails every 60 days, recovers in 60 minutes 99.9306 % 30.0 minutes
Fails every 30 days, recovers in 5 minutes 99.9884 % 5.0 minutes

Halving the failures halves the downtime; cutting the recovery to a twelfth cuts it to a twelfth.

Checkpoint

Check: MTBF and MTTR

  1. Question 1 of 2 A service fails on average every 20 days and takes 30 minutes to recover. What is its availability, in percent to three decimal places?

    Type a number.

    A hint

    Work in hours. MTBF is 20 × 24 hours and MTTR half an hour.

    Show the answer: Question 1 of 2

    Answer: 99.896 % (anything from 99.895 to 99.897 counts)

    A = MTBF ÷ (MTBF + MTTR) = 480 ÷ 480.5 ≈ 0.99896, or 99.896 %. Recovering in 5 minutes instead would give 480 ÷ 480.083 ≈ 99.983 % without making failures any rarer.

  2. Question 2 of 2 A service fails every 30 days and needs an hour to recover. Which change buys more availability?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: Recovering in 5 minutes instead of 60, which gives 99.9884 %

    The program's last block compares them: 99.8613 % today, 99.9306 % with half the failures and 99.9884 % with 5-minute recovery. Fast detection, automatic failover and quick rollback are often cheaper than rarer failures.

Correlated failures break the parallel formula

The parallel formula’s promise, 99.99% from two 99% parts, holds only if one part’s failure tells you nothing about the other’s. Replicas that share a power feed, a network switch, a configuration push, a deploy or a software bug fail together. This simulation gives two replicas the same individual availability twice, once with independent failures and once with a shared cause that takes both down about four times a year for about an hour:

Two 99% replicas, independent and with a shared cause Python · correlated/correlated.py
"""Two replicas, each up 99% of the time: independent failures against a shared cause.

Each replica fails on its own about once a month and takes about 7.3 hours to repair, so it is down about 1% of
the time. In the second case the pair also shares a cause (one power feed, one configuration push, one region)
that takes both down at once about four times a year, for about an hour. Failures are simulated over 2,000 years
with a fixed seed; the numbers are assumptions for the sketch.
"""

import random

HOURS = 2_000 * 8_766  # 2,000 years of 365.25 days
rng = random.Random(3)


def outages(mtbf_h, mttr_h):
    """Random down intervals (start, end) in hours: up for about mtbf_h, then down for about mttr_h."""
    t, spans = 0.0, []
    while True:
        t += rng.expovariate(1 / mtbf_h)
        if t >= HOURS:
            return spans
        down = rng.expovariate(1 / mttr_h)
        spans.append((t, min(t + down, HOURS)))
        t += down


def merged(spans):
    """The same down time as non-overlapping intervals, in order."""
    out = []
    for start, end in sorted(spans):
        if out and start <= out[-1][1]:
            out[-1] = (out[-1][0], max(out[-1][1], end))
        else:
            out.append((start, end))
    return out


def both_down(a, b):
    """Hours during which both replicas are down."""
    a, b, total, i, j = merged(a), merged(b), 0.0, 0, 0
    while i < len(a) and j < len(b):
        total += max(0.0, min(a[i][1], b[j][1]) - max(a[i][0], b[j][0]))
        if a[i][1] < b[j][1]:
            i += 1
        else:
            j += 1
    return total


replica_a, replica_b = outages(720, 7.27), outages(720, 7.27)
shared = outages(8_766 / 4, 1)  # about four times a year, about an hour each
alone = sum(end - start for start, end in merged(replica_a)) / HOURS

print(f"one replica on its own:          {100 * (1 - alone):.3f}% available")
for name, extra in [("two replicas, independent", []), ("two replicas, shared cause", shared)]:
    down = both_down(replica_a + extra, replica_b + extra) / HOURS
    print(f"{name + ':':33}{100 * (1 - down):.3f}% available, down {down * 8_766:.1f} h a year")
print(f"formula for independent replicas: {100 * (1 - alone**2):.3f}%")

Output

one replica on its own:          98.992% available
two replicas, independent:       99.989% available, down 0.9 h a year
two replicas, shared cause:      99.944% available, down 4.9 h a year
formula for independent replicas: 99.990%

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 correlated.py

Each replica on its own is about 99% available, and independently the pair reaches 99.989%, about 0.9 hours of downtime a year, close to the formula’s 99.990%. Four hour-long shared events a year cost the pair five times as much downtime, 4.9 hours, and the shared cause now dominates: once failures are correlated, adding replicas that share the cause adds almost nothing. Step through the four kinds of failure the simulation draws:

Interactive · step by step Two replicas, alone and with a shared cause Step through four failures. The pair is down only while both replicas are, which a shared cause makes far more likely.
Two replicas, alone and with a shared cause, step 5 of 5. Showing Requests, Replica A (up), Replica B (up), One power feed (back).RequestsReplica AupReplica BupOne power feedback

The drawing shows the whole scene; its 5 steps are listed below.

Every step as text
  1. Replica A fails alone. Replica A's disk fails. Replica B answers every request, so users see nothing. Each replica is down about 1 % of the time.
  2. Replica B fails alone. Later B fails on its own and A carries the load. Independent failures overlap only by chance, about 1 % of 1 % of the time.
  3. Both by chance. Rarely, both are down at once by bad luck. Over the simulated years the pair was down 0.9 hours a year this way, close to the formula's 99.99 %.
  4. The shared feed fails. The power feed both replicas use fails, and both go down at the same moment. Redundancy did nothing, because the two shared the cause.
  5. What it costs. Four such hour-long events a year raise the pair's downtime from 0.9 to 4.9 hours a year. Separate what the replicas share before adding a third.

Measurements of real fleets agree. A year-long study of Google’s storage clusters by Ford and colleagues found that a large share of node failures came in bursts, that most large bursts were tied to a rack or a group of racks, and that modelling the same failures as independent typically overestimated how long data stays available by two orders of magnitude or more. Correlation also shrank the gain from adding replicas.

Amazon’s Builders’ Library describes correlated failure: Several parts failing at once from one cause they share, such as a power feed, a configuration push, a deploy or a software bug. It breaks the parallel formula, which assumes independent failures. as several components failing from the same underlying cause, and lists causes beyond the obvious ones: data-centre power, networking and cooling; shared dependencies such as DNS; deployments and tools that act on many servers at once; every server running the same software with the same limits; and many clients changing their behaviour at the same moment. Its remedies are the design moves that the rest of this track uses:

  • Independent zones. Run separate copies of the service in each zone, sharing as little as possible with other zones, so a facility problem stays in one zone.
  • Staggered changes. Deploy and change configuration in one zone, or one cell, at a time, so a bad change fails small.
  • Cells and shuffle sharding: Giving each customer its own small, random set of workers from a shared fleet, so that two customers rarely share all of their workers and one customer's bad requests reach few others. More in “Cells, deployment stamps and blast radius”. Split the fleet into independent cells, and give customers different combinations of servers, so that no single failure or bad workload reaches everyone.
  • Jitter. Add a little randomness to timers, retry delays, cache expiry and limits, so that servers do not all hit the same edge at the same moment.
Time Unit Converter Turn a downtime budget such as 52.6 minutes a year into seconds, hours or days.

Key idea

The parallel formula holds only for independent failures; replicas that share a cause fail together, so separate what they share before you add another one.

Checkpoint

Check: Correlated failures

  1. Question 1 of 2 In the lesson's simulation, what did four hour-long shared events a year do to the downtime of two 99 % replicas?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: They raised it about fivefold, from 0.9 hours a year to 4.9 hours a year

    Independently the pair was down 0.9 hours a year, close to the formula's 99.99 %. With four shared hour-long events, the shared cause dominated: 4.9 hours, five times as much.

  2. Question 2 of 2 Two replicas share one power feed, and the feed's failures cause most of their joint downtime. A third replica is added on the same feed. What does it change?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: Almost nothing, because the feed still takes all three down at once

    Correlated failures put a floor under the downtime that more of the same replicas cannot lower. Separate what the replicas share, such as the power feed, the zone or the deploy, before adding more of them.

Practise: availability from parts

Write four helpers in Python: the downtime a target allows, and the availability of parts in series, in parallel and from MTBF and MTTR. Their sample tests run here:

Exercise · Easy · Python

Downtime budgets and composite availability

Write four helpers in availability.py. Availabilities go in and come out as percentages, so 99.9 means 99.9%.

downtime_minutes(target_pct, days) returns the minutes of downtime that a target allows over days days. For example, downtime_minutes(99.9, 30) is 43.2.

series(*parts_pct) returns the availability of parts that are all needed for a request to succeed, such as a load balancer, an app tier and a database called one after the other. For example, series(99.9, 99.9) is 99.8001.

parallel(*parts_pct) returns the availability of redundant parts of which any one is enough, assuming they fail independently. For example, parallel(99, 99) is 99.99.

from_mtbf(mtbf_hours, mttr_hours) returns the availability of a part that runs for mtbf_hours on average between failures and takes mttr_hours on average to recover. For example, from_mtbf(720, 1) is about 99.8613.

Starter code · availability.py

def downtime_minutes(target_pct, days):
    """Minutes of downtime that target_pct allows over `days` days."""
    # Replace this line with your code.
    return 0


def series(*parts_pct):
    """Availability, in percent, of parts that are all needed."""
    # Replace this line with your code.
    return 0


def parallel(*parts_pct):
    """Availability, in percent, of independent redundant parts of which any one is enough."""
    # Replace this line with your code.
    return 0


def from_mtbf(mtbf_hours, mttr_hours):
    """Availability, in percent, from the mean time between failures and the mean time to recover."""
    # Replace this line with your code.
    return 0
The sample tests · test_availability.py
import math

from availability import downtime_minutes, from_mtbf, parallel, series


def close(a, b):
    return math.isclose(a, b, abs_tol=1e-6)


def test_downtime_minutes():
    """turns a target into minutes of downtime over a period"""
    assert close(downtime_minutes(99.9, 30), 43.2)
    assert close(downtime_minutes(99.95, 30), 21.6)
    assert close(downtime_minutes(99.99, 365.25), 52.596)
    assert close(downtime_minutes(100, 30), 0)


def test_series():
    """multiplies the availabilities of parts that are all needed"""
    assert close(series(99.9, 99.9), 99.8001)
    assert close(series(99.99, 99.95, 99.9), 99.840064995)
    assert close(series(99.5), 99.5)


def test_parallel():
    """is down only when every redundant part is down"""
    assert close(parallel(99, 99), 99.99)
    assert close(parallel(99.5, 99.5), 99.9975)
    assert close(parallel(90, 90, 90), 99.9)
    assert close(parallel(80), 80)


def test_from_mtbf():
    """is the share of time up between failures"""
    assert close(from_mtbf(720, 1), 100 * 720 / 721)
    assert close(from_mtbf(720, 5 / 60), 100 * 720 / (720 + 5 / 60))
    assert close(from_mtbf(99, 1), 99)
A hint

Turn each percentage into a fraction first (p / 100) and back at the end. In series, multiply the fractions. In parallel, multiply the chances that each part is down (1 - fraction) and subtract the product from 1. For the mean times, the part is up for MTBF out of every MTBF + MTTR hours.

The sample tests run on this device, in your browser (Pyodide): nothing is sent to mysmartcopilot.com. The first run downloads Python (about 13.5 MB), which is kept for the next runs. A check in your browser is feedback for you, not proof that the code is right for every input.

Then practise on new paths and replicas, one question at a time, starting from the formula you have missed most:

Practice that adapts to you

Practise this lesson

11 questions about 5 ideas of this lesson. Each answer is explained at once, and what you get right is kept in this browser.

  1. Question 1 of 11 How many nines is 99.95 %?

    Choose one answer.

    Show the answer: Question 1 of 11

    Answer: About 3.3

    The count of nines is −log10(1 − availability): 99.9 % is 3, 99.95 % about 3.3 and 99.99 % is 4. Each whole nine divides the allowed downtime by ten.

  2. Question 2 of 11 How many minutes of downtime does a 99.95% target allow in a 30-day month?

    Type a number.

    Show the answer: Question 2 of 11

    Answer: 21.6 minutes (anything from 21.55 to 21.65 counts)

    A 30-day month has 30 × 24 × 60 = 43,200 minutes, and 0.05% of them is 21.6 minutes. Two incidents of a quarter of an hour already break it.

  3. Question 3 of 11 For parts in series whose unavailabilities are small, what is a quick way to estimate the whole?

    Choose one answer.

    Show the answer: Question 3 of 11

    Answer: Add the unavailabilities

    0.01 % + 0.05 % + 0.1 % = 0.16 % of failure gives 99.84 %, the same as the product 0.9999 × 0.9995 × 0.999 to two decimals.

  4. Question 4 of 11 A request passes a load balancer (99.99%), an app tier (99.95%) and a database (99.9%), and needs all three. What is the path's availability, in percent to two decimal places?

    Type a number.

    Show the answer: Question 4 of 11

    Answer: 99.84 % (anything from 99.83 to 99.85 counts)

    In series the availabilities multiply: 0.9999 × 0.9995 × 0.999 ≈ 0.9984, or 99.84%. A quick check: the unavailabilities add up for small values, 0.01 + 0.05 + 0.1 = 0.16%, so 99.84%.

  5. Question 5 of 11 Which formula gives the availability of two independent redundant parts, A1 and A2, when either one is enough?

    Choose one answer.

    Show the answer: Question 5 of 11

    Answer: 1 − (1 − A1)(1 − A2)

    Redundancy multiplies the chances of failure: two 99 % parts are both down 0.01 × 0.01 = 0.01 % of the time, so the pair is up 99.99 %.

  6. Question 6 of 11 Two replicas, each 99.5% available and failing independently, serve the same data; either one is enough. What is the pair's availability, in percent to four decimal places?

    Type a number.

    Show the answer: Question 6 of 11

    Answer: 99.9975 % (anything from 99.9974 to 99.9976 counts)

    Both are down at once with probability 0.005 × 0.005 = 0.000025, so the pair is up 99.9975% of the time, if their failures really are independent.

  7. Question 7 of 11 Three app instances are each 99% available, and the peak needs any two of them. What is the tier's availability, in percent to two decimal places?

    Type a number.

    Show the answer: Question 7 of 11

    Answer: 99.97 % (anything from 99.96 to 99.98 counts)

    The tier is up when all three are up (0.99³ = 0.970299) or exactly two are (3 × 0.99² × 0.01 = 0.029403), which adds up to 0.999702, or 99.97%. Needing two of three is weaker than needing one of three (99.9999%).

  8. Question 8 of 11 What do MTBF and MTTR stand for in A = MTBF ÷ (MTBF + MTTR)?

    Choose one answer.

    Show the answer: Question 8 of 11

    Answer: The mean time between failures and the mean time to recover

    Availability in mean times is the share of each cycle spent working: a part that runs 720 hours and then needs one hour is up 720 ÷ 721 = 99.8613 % of the time.

  9. Question 9 of 11 A service fails on average every 10 days and takes 1 hour to recover. What is its availability, in percent to two decimal places?

    Type a number.

    Show the answer: Question 9 of 11

    Answer: 99.59 % (anything from 99.58 to 99.6 counts)

    Availability is MTBF ÷ (MTBF + MTTR) = 240 ÷ 241 ≈ 0.99585, or 99.59%. Cutting recovery to 6 minutes would give 240 ÷ 240.1 ≈ 99.96% without making failures any rarer.

  10. Question 10 of 11 What makes the failures of two replicas correlated?

    Choose one answer.

    Show the answer: Question 10 of 11

    Answer: A cause they share, such as one power feed, one configuration push or one software bug

    The Builders' Library describes correlated failures as several components failing from the same underlying cause: shared power, networking, dependencies, deployments, software and client behaviour.

  11. Question 11 of 11 Two database replicas sit in the same rack, on one power feed, and receive configuration from the same push. Which change adds the most availability?

    Choose one answer.

    Show the answer: Question 11 of 11

    Answer: Moving one replica to another zone, with its own power and network, and pushing configuration to one replica at a time

    The parallel formula assumes the replicas fail independently, and these share a rack, a power feed and a configuration push, so one event takes both down. Separating what they share removes the common causes; a third replica in the same rack fails with the other two.

Design practice: targets you can defend

Availability targets are where a design round checks your arithmetic and your scepticism. Commit to a first answer for each brief, then check it with the checkout path and the shared-cause simulation:

Checkpoint

Your first decision

  1. Question 1 of 2 Design brief: product wants checkout at 99.99 %, but the database it depends on is rated 99.95 %. What do you say first?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: In series checkout cannot beat its weakest hard dependency, so the database must get more available or checkout must keep working while it is down

    Turn both into minutes: 4.32 minutes a month for checkout, 21.6 for the database on its own. Either the database's availability rises, or checkout stops depending on it for every request.

  2. Question 2 of 2 Design brief: a teammate says three replicas, each 99 % available, give the service 99.9999 %. What do you ask before you accept that number?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: Whether they fail independently, so where they run and what they share, and how many are needed at the peak

    Shared racks, zones, power, deploys and software versions make replicas fail together, and a peak that needs two of three gives far less than "any one". Ask about both before trusting six nines.

Model answers open with any pass: ₹79 for 1 week ($2.99), one payment that never renews.

  1. Mid to senior

    Product wants the checkout service at 99.99% availability, but the database it depends on is rated 99.95%. Is the target reachable? Explain with numbers, and say what you would change.

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page. First step and follow-ups

  2. Mid to staff

    A teammate says that three replicas, each 99% available, give the service 99.9999% availability. What do you ask before you accept that number, and what would you estimate instead?

    Model answer, Pro. First step and follow-ups

Interview questions

Warm-up (fresher to mid level): two services, each 99.9% available, must both work for a request to succeed. What availability can the pair offer, and why? About 99.8%. The request needs both, so it succeeds only when both are up at once: 0.999 × 0.999 = 0.998001, assuming they fail independently. A quick way to see it is that the unavailabilities roughly add up: 0.1% + 0.1% = 0.2% of failures, about 86 minutes a month instead of 43. That is why every hard dependency lowers the ceiling of a design, and why designs remove dependencies from the critical path, add redundancy inside them, or make them soft dependencies that the service can work without for a while.

Key takeaways

  • Turn targets into downtime over a stated period: 99.9% is 43.2 minutes per 30-day month and 8.77 hours per year; each nine divides it by ten.
  • In series, availabilities multiply and unavailabilities roughly add: every hard dependency lowers the ceiling.
  • In parallel, the group fails only when every part has failed: two independent 99% replicas give 99.99%, but “any 2 of 3” and failover time give less.
  • A = MTBF ÷ (MTBF + MTTR): faster detection and recovery often buy more nines than rarer failures.
  • Shared causes (power, deploys, configuration, software, zones) make replicas fail together; separate what they share before adding more of them.

Terms in this lesson

correlated failure
Several parts failing at once from one cause they share, such as a power feed, a configuration push, a deploy or a software bug. It breaks the parallel formula, which assumes independent failures.
hard dependency
A part that every request needs, so the service fails whenever it does. Hard dependencies are in series, and each one lowers the availability the whole service can reach.
mean time between failures (MTBF)
The average time a part runs between one failure and the next. With the mean time to recover, it gives the part's availability: MTBF divided by MTBF plus MTTR.
mean time to recover (MTTR)
The average time from a failure until the part works again, detection included. Cutting it from 60 minutes to 5 took a monthly failure from 99.8613 % to 99.9884 %.

References

Related tools

Report a problem with this lesson

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.