AlgoViz

Defining high availability

easy 25 min

Availability is the share of time, or of requests, that a system works for its users.

Video lesson · Chapter 1 of 6

What one more nine buys

0:00 / 5:33

The nines in 80 seconds

1:20Reel coming soon

Theory

Read or listen first. About 2 min.

What it is

Availability is the share of time that a system can do its job for its users. If a shop website works for 999 hours out of 1,000, its availability is 99.9%.

High availability (HA) is a design goal: the system keeps working for an agreed, very high share of the time, even when parts of it break. It is always a number with a period. "Always up" is a wish, "99.9% of requests in a month" is a target.

Why it exists

Every machine, cable and program fails sometimes, and people change software every week. Without a target nobody can say whether one broken evening a month is fine or a disaster.

A number settles that. It tells engineers how much spare equipment to buy, tells the business what a promise may cost, and tells everybody when to stop shipping features and fix things. Each extra nine is ten times harder to keep, so the right target is the lowest one your users are happy with.

A short history

  1. 1976

    The first Tandem/16, sold as NonStop, ships to Citibank. It is built from duplicated parts so that one failure does not stop work.

  2. 1985

    Jim Gray publishes "Why Do Computers Stop and What Can Be Done About It?", which shows that administration and software, not only hardware, cause outages.

  3. 2008

    Amazon EC2 leaves beta and adds a service level agreement. Availability becomes something you buy with a refund attached.

  4. 2016

    Google publishes the book Site Reliability Engineering. Service level objectives and error budgets become common words.

Words to know

Uptime
Time when the system works and serves users.
Downtime
Time when users see errors or cannot reach it.
Nines
How many nines the percentage has. 99.99% is four nines.
MTBF
Mean time between failures: how long it runs, on average, before something breaks.
MTTR
Mean time to recovery: how long a break lasts, on average.
SLI
Service level indicator: what you measure.
SLO
Service level objective: the target you set for yourself.
SLA
Service level agreement: the promise in a contract, with a penalty.
Error budget
The downtime or failed requests the SLO still allows.

How it works

Step through the idea, or press Play.

Step 1 of 3

Pick a target. How many nines the users need, for which requests, over which period

Understand it

Start here

The ice cream shop

Imagine you have a favourite ice cream shop. You love it, but sometimes you walk there and it is closed. How often it is closed over a whole year is its availability. A shop with five nines is almost never closed: about 5 minutes in a year.

How often is the shop closed?
ICE CREAMOpen

Nobody asks whether the shop is ever closed. They ask how long, and whether it was closed when they came.

The formula

How availability is worked out

Availability over time

A=total time−downtimetotal time×100%43,200−43.243,200=99.9%A = \frac{\text{total time} - \text{downtime}}{\text{total time}} \times 100\% \qquad \frac{43{,}200 - 43.2}{43{,}200} = 99.9\%
A 30-day month has 30×24×60=43,20030 \times 24 \times 60 = 43{,}200 minutes. Losing 43.2 of them is exactly three nines.
  • Uptime

    Time when the system works and serves users. The good time.

  • Downtime

    Time when users see errors or cannot get in. The bad time.

  • Availability %

    The score. Higher is better, and more expensive.

With high availability

  • A server crashes on the biggest sale day
  • A spare takes over within seconds
  • Most customers never notice

Without it

  • The same server crashes
  • The shop shows errors until someone repairs it
  • Customers buy somewhere else

The nines

How much downtime does a target allow?

We count how many nines are in the percentage. Every extra nine leaves ten times less downtime.

Allowed downtime

NinesAvailabilityPer year (365 days)Per month (30 days)Where you might see it
299%3.65 days7.2 hoursInternal tools, batch jobs
399.9%8.76 hours43.2 minBusiness apps
3 and a half99.95%4.38 hours21.6 minManaged databases
499.99%52.6 min4.3 minLarge shops, payment pages
599.999%5.3 min25.9 sCore payment and telephone systems
699.9999%31.5 s2.6 sVery rarely promised
The last column is an illustration, not a rule: the users and the money decide. Two nines feels unreliable, three acceptable, four good, five excellent.

The 10x rule

D(A)=(1−A)×T0.001×8,760 h=8.76 h  →  0.0001×8,760 h=0.876 h=52.6 minD(A) = (1 - A) \times T \qquad 0.001 \times 8{,}760\,\text{h} = 8.76\,\text{h} \;\to\; 0.0001 \times 8{,}760\,\text{h} = 0.876\,\text{h} = 52.6\,\text{min}
TT is the period. One more nine divides 1−A1 - A by ten, so it divides the downtime by ten.

Measuring

MTBF and MTTR

Two averages explain every availability number: how often it breaks, and how long each break lasts.

A system's life

MTBF covers the running part. MTTR covers everything from the failure until users are served again, including the minutes before anyone notices.

A worked month: 720 hours, 3 failures, 90 minutes down

MetricMeaningCalculationResultBetter is
MTBFMean time between failures(720 h - 1.5 h) / 3239.5 hHigher
MTTRMean time to recovery90 min / 330 minLower
AvailabilityMTBF / (MTBF + MTTR)239.5 / 24099.79%Higher
Here MTBF is the mean *running* time between failures. Some books count the repair too, then availability is (MTBF - MTTR) / MTBF. Say which one you use.

Two levers

A=MTBFMTBF+MTTR99.99%:  MTTR=239.5 h9,999≈86 s   or   MTBF=0.5 h×9,999≈208 daysA = \frac{\text{MTBF}}{\text{MTBF} + \text{MTTR}} \qquad 99.99\%:\; \text{MTTR} = \frac{239.5\,\text{h}}{9{,}999} \approx 86\,\text{s} \;\text{ or }\; \text{MTBF} = 0.5\,\text{h} \times 9{,}999 \approx 208\,\text{days}
To take that month to four nines, keep the same failures and recover in 86 seconds, or keep 30-minute repairs and fail once in 208 days. Faster recovery is usually the cheaper lever.

Raise MTBF: fail less often

  • Better tests and code quality
  • Redundant parts
  • Proactive monitoring and alerts
  • Capacity planning

Lower MTTR: recover faster

  • Automatic failover
  • Runbooks and playbooks
  • On-call people and clear escalation
  • Fast rollback

Chains

Parts in a row multiply

A request usually needs several parts, and it fails if any of them fails. So their availabilities multiply, and the result is lower than the worst part.

One of each: three things that can stop you

Users call a load balancer with 99.99 percent availability, which calls an app machine with 99.95 percent, which calls a database machine with 99.95 percent. All three sit inside our system.
Every box is needed for every request. Together they reach about 99.89%, although no box is below 99.95%.

Availability of a chain

A=∏iAi0.9999×0.9995×0.9995=0.9989≈47.5 min a monthA = \prod_i A_i \qquad 0.9999 \times 0.9995 \times 0.9995 = 0.9989 \approx 47.5\ \text{min a month}
This assumes the parts fail independently. Ten services of 99.9% in a row give 0.99910=99.0%0.999^{10} = 99.0\%.

The same chain with spares

The same system with a spare of each machine: the load balancer sends requests to two app machines, both use a primary database machine, which sends every change to a standby database machine.
Two app machines, and a standby that receives every change. How the switch works is in Achieving high availability.

Hard or soft dependency?

Recommendations that fail should leave an empty shelf, not an error page. Making a dependency soft is often cheaper than making it more available.

Time or requests

Two ways to count

Time-basedRequest-based
FormulaUp minutes / all minutesGood requests / all requests
Good forOne system that is up or downAnything that can be partly broken
20 minutes down at 4 amCosts 20 minutesCosts little: few requests
5% errors for 2 hoursUp or down? UnclearLike 6 minutes of full outage
NeedsA rule for what counts as downA count from the load balancer or the client
Large systems are rarely all down, so request-based counting is usually fairer: 10 million requests a month at 99.9% leaves 10,000 that may fail.

Promises

SLI, SLO and SLA

Three names, one order: measure, target, promise.

Full nameWhat it isExample
SLIService level indicatorWhat you really measureGood requests this month: 99.97%
SLOService level objectiveYour own target, stricter than the SLA99.95% of requests a month
SLAService level agreementA contract with customers; breaking it costs credits or penalties99.9%, or part of the bill is returned
Healthy order: SLI 99.97% is above SLO 99.95%, which is above SLA 99.9%.

How they work together

The gap between SLO and SLA is your warning time: you find out inside the company before it costs money outside.

A real contract: the Amazon EC2 region SLA promises 99.99% a month. Below that, credits are 10% of the bill, below 99.0% 30%, below 95.0% 100%. A single instance is only promised 99.5%. Credits are small compared with what an outage costs you, so an SLA is not a plan.

Error budget

Spending the downtime you are allowed

If the SLO is 99.95%, then 0.05% may fail. That is the error budget: 21.6 minutes in a 30-day month. Releases, experiments and maintenance all spend it.

What to do with the budget

The budget ends the argument between speed and safety: the number decides.

Burn rate

burn=error rate now1−SLO1.44%0.1%=14.4  ⇒  720 h14.4=50 h until empty\text{burn} = \frac{\text{error rate now}}{1 - \text{SLO}} \qquad \frac{1.44\%}{0.1\%} = 14.4 \;\Rightarrow\; \frac{720\,\text{h}}{14.4} = 50\,\text{h until empty}
Burn 1 uses the budget exactly in the period. At 14.4, one hour uses 2% of the month: wake somebody up.

Do not mix up

Four words that are not the same

WordQuestion it answersExample
AvailabilityCan I use it now?The photo opens
DurabilityIs my data still there?The photo was not lost
ReliabilityDoes it do the right thing over time?It opens the right photo, every day
Fault toleranceDoes a failure show at all?A disk died and nobody noticed
Amazon S3 Standard shows the difference: designed for 99.999999999% durability (11 nines), but its SLA for availability is 99.9%. For 10 million objects, 11 nines means losing one object in about 10,000 years on average.

Money

What a nine is worth

A worked decision (assumed numbers)

  1. 1

    Sales per minute

    A shop sells 12millionayear:12 million a year: 12,000,000 / 525,600 = about 23aminute,andabout23 a minute, and about 68 at a peak of 3x.

  2. 2

    Downtime saved by one nine

    From 99.9% to 99.99%: 8.76 h - 0.88 h = 7.88 h, about 473 minutes a year.

  3. 3

    Value of that nine

    473 x 23=about23 = about 10,900 a year in direct sales.

  4. 4

    Decide

    If a second region costs $60,000 a year, it does not pay for itself on sales. Trust, contracts and safety can still justify it, but say that aloud.

What five nines asks for

  • Several data centers

    Spares of everything, in places that do not fail together.

  • Failover in seconds

    5.3 minutes a year leaves no room for a human repair.

  • People on call

    Engineers day and night, for what automation does not know.

  • Live monitoring

    Real-time measurements and alerts on what users feel.

  • Chaos engineering

    Break parts on purpose, so that the first failover is not the real one.

  • Tests and runbooks

    Every release is tested and every known failure has written steps.

Summary

The whole topic in one minute.

Availability is good time divided by total time, or good requests divided by all requests. Counting nines is a short way to say it: each extra nine cuts the allowed downtime by ten.

Two levers move it: fail less often (MTBF up) or recover faster (MTTR down). Parts in a chain multiply, so a system is worse than its weakest part. Measure an SLI, hold it to an SLO, promise a looser SLA, and spend the gap, the error budget, on change.

  • Availability is uptime over total time, or good requests over all requests.
  • 99.9% is 43.2 minutes a month, 99.99% is 4.3. Each nine is 10x less.
  • A = MTBF / (MTBF + MTTR): fail less, or recover faster.
  • Parts in a row multiply. Three at about 99.95% give about 99.9%.
  • SLI is measured, SLO is the target, SLA is the promise. The error budget is what the SLO leaves.

Sources