Availability and reliability
Turn "it must not go down" into numbers: what each nine allows, how redundancy and failover change the maths, and how SLOs and error budgets guide decisions.
The problem
A payments team promises its largest customer “high availability” in a contract. In March a database failover takes 40 minutes, because nobody has run the procedure since it was written. The customer says the promise is broken. The team says one outage in a year is excellent. Neither can be shown to be wrong, because “high availability” is not a number.
The team’s first response is hardware: a second database server and a second load balancer. The next outage is a bad configuration push that reaches both database servers in the same minute. The redundancy does nothing, because both copies share the cause of failure. So the team swings the other way and freezes all changes for a quarter. Nothing breaks, and nothing ships.
What is missing is a way to state how much failure is acceptable, to calculate what a design can deliver, and to decide when to spend effort on reliability and when on features.
Three words that are not synonyms
- Availability is the fraction of time, or better the fraction of requests, for which the system gives a correct response.
- Reliability is the probability that the system keeps working correctly over a period. It is about how often failures happen, not how long they last.
- Durability is the probability that data, once stored, is not lost.
They come apart. A service that drops every connection for one second each hour is 99.97% available, yet no two-hour upload ever completes without a retry. A system that fails once a year and takes a day to repair is reliable but only 99.7% available. Amazon S3 Standard is designed for eleven nines of durability but 99.99% availability: your object is almost certainly safe, even during an hour when you cannot fetch it.
The nines
| Availability | Downtime per year | Downtime per 30 days |
|---|---|---|
| 99% | 3.65 days | 7.2 hours |
| 99.9% | 8.76 hours | 43 minutes |
| 99.95% | 4.38 hours | 22 minutes |
| 99.99% | 53 minutes | 4.3 minutes |
| 99.999% | 5.3 minutes | 26 seconds |
Each nine divides the allowance by ten, and changes how you must operate. At 99.9% a person can be paged, wake up and fix the problem. At 99.99% a single one-hour incident spends more than the year’s allowance, so recovery has to be automatic. At 99.999% even an automatic failover that takes a minute can happen only five times a year.
Series and parallel
In series, a request needs every component, so availabilities multiply. Three components at 99.9% give 99.7%. A service that needs ten dependencies at 99.9% each can be no better than about 99%.
In parallel, the group fails only when every member fails, so you multiply the unavailabilities. Two servers at 99% give 1 − (0.01 × 0.01), which is 99.99%.
In this design the pair of app servers is 1 − 0.001², or 99.9999%. The whole path is 0.9999 × 0.999999 × 0.9995, about 99.94%. The single database dominates the result, and improving the app tier further would change nothing. Find the weakest component in the series and make that one redundant.
The parallel formula assumes independent failures and perfect failover, and neither is true. Replicas fail together when they share a rack, a deployment, an expired certificate or an overloaded dependency. And when one of two servers dies, the survivor takes all the traffic. If each was running at 70%, the survivor fails too. Treat the calculated figure as an upper bound.
Redundancy and failover
Active-passive. One node serves and a standby waits. A hot standby is running and replicating, and can take over in seconds. A cold one must be started and restored, which takes minutes to hours. The arrangement is simple and has no write conflicts, but you pay for idle capacity, and the failover itself takes time and can go wrong.
Step 1 of 8
In normal running, every read and write goes to the primary database. The standby receives a copy of each change and serves no traffic. It exists only to take over.
Read the steps as text
- In normal running, every read and write goes to the primary database. The standby receives a copy of each change and serves no traffic. It exists only to take over.
- A failover manager sends each database a heartbeat every second or so. While the answers keep coming back, it does nothing.
- The primary's machine dies. Requests from the app start to time out, and the heartbeats go unanswered. Nothing has decided to fail over yet, so the service is simply down.
- The manager waits for several missed heartbeats before it acts, because a slow network looks the same as a dead server. A short timeout recovers faster but sometimes fails over when it should not. A long one is safer but adds downtime.
- Before promoting the standby, the manager fences the old primary, for example by cutting its access to storage or the network. Without fencing, a primary that was only slow could wake up and accept writes as well. That is called split brain.
- The standby is promoted and starts accepting writes. If replication was asynchronous, the last few changes the old primary accepted may never have arrived. That gap is the recovery point: data that was acknowledged to users and then lost.
- Clients must now find the new primary. The manager updates a virtual IP address, a DNS record or the service registry, and the app reconnects. Until every client has moved over, some requests still fail.
- The outage lasted for detection, plus the decision, plus promotion, plus redirecting clients. That total is the recovery time. Active-passive is simple and safe, but it is only as good as the last time you rehearsed this sequence.
Active-active. Every node serves. There is no promotion step: a failed node’s traffic shifts to the others. Each node needs spare capacity, so two nodes must each stay under 50%. For databases, two nodes accepting writes means conflicting writes, covered in replication and CAP and PACELC.
When to choose which. Use active-active for stateless services, always. For databases, a single leader with automated failover is the default. Choose multi-writer active-active only when writes must survive the loss of a region with no failover delay, or users in several regions need local write latency, and you can live with resolving conflicts.
Two figures describe a failover. The recovery time objective (RTO) is how long you may be down. The recovery point objective (RPO) is how much recent data you may lose. Asynchronous replication means the RPO is not zero.
Failure domains
A failure domain is a set of things that fail together: a process, a host, a rack, an availability zone (one or more data centres with independent power and networking), a region. Some domains are not physical: a software version, a configuration push, a shared dependency.
Place replicas in different domains, chosen by the failure you need to survive. Three zones cover the loss of a zone. A second region covers the loss of a region, at much higher cost. Roll changes out gradually, to one zone or a few percent of users first, so that a bad change is a small failure.
SLIs, SLOs, SLAs and error budgets
These terms come from Google’s site reliability engineering practice.
- An SLI (indicator) is a measurement, usually good events divided by all events: the share of requests answered without a server error in under 300 ms.
- An SLO (objective) is the target: 99.9% over a rolling 30 days.
- An SLA (agreement) is a contract with customers, with a penalty such as service credits. It is usually looser than the SLO, so you get a warning before it costs money.
The error budget is 1 minus the SLO. At 99.9% and 100 million requests a month, the budget is 100,000 failed requests. While budget remains, ship freely. When it is spent, pause risky releases and work on reliability. This turns the argument between “move fast” and “do not break things” into arithmetic, which is what the payments team needed.
MTBF and MTTR
availability = MTBF ÷ (MTBF + MTTR)
MTBF is the mean time between failures, and MTTR the mean time to recover. A service that fails every 30 days and takes an hour to recover is 720 ÷ 721, or 99.86% available. Cut recovery to six minutes and it is 99.986%. Making failures ten times rarer would give the same gain and is usually much harder. This is why fast detection, automated failover and quick rollback are the first investments.
Graceful degradation
Availability does not have to be all or nothing. When a dependency fails, serve less instead of serving an error: show stale data from a cache, hide recommendations, switch to read-only, or shed low-priority traffic. The tools are timeouts and retries and circuit breakers. Decide for each dependency whether it is hard (you cannot serve without it) or soft. Every soft dependency drops out of the series calculation.
How many nines to aim for
Each extra nine costs far more than the last: redundancy across zones and then regions, automation, on-call and slower change. Aim for what users notice and the business needs. An internal reporting tool is fine at 99%. A payments API may justify 99.99%. Beyond that, the user’s own device and network are usually the weaker link.
In the interview
Ask for the availability target during requirements and translate it: “99.99% is under an hour a year, so failover cannot be manual.” As you draw, point at each single point of failure and say what replaces it. Then walk through one failure: how it is detected, what takes over, and what is lost.
A strong one-minute answer: “The stateless tier is active-active across three zones. The database is a single leader with a synchronous standby in a second zone and automated failover, so the recovery point is zero and recovery takes under a minute. The cache and the recommendation service are soft dependencies. I would measure availability as successful requests at the load balancer against a 99.95% SLO.”
Key takeaways
- Availability is the share of time or requests served correctly. Reliability is how long the system runs without failing. Durability is whether stored data survives.
- Each nine cuts the downtime allowance tenfold: 99.9% is about 8.8 hours a year, 99.99% about 53 minutes and 99.999% about 5 minutes.
- Components in series multiply their availabilities, so a chain is worse than its weakest link. Redundant components multiply their failure probabilities, but only if they fail independently.
- Redundancy helps only when failover is fast, tested and fenced against split brain.
- Availability is MTBF divided by MTBF plus MTTR. Cutting recovery time is usually cheaper than preventing failures.
- The SLI is the measurement, the SLO is the target and the SLA is the contract. The error budget is what the SLO lets you spend on change.
- Degrade gracefully. A page without recommendations is better than an error page.
Check yourself
0 of 5 answered
Flashcards
These 6 cards are in your review deck. Tap a card to see the answer.
Downtime allowed per year at 99.9%, 99.99% and 99.999%
About 8.8 hours, 53 minutes and 5 minutes.
Series and parallel formulas
Series: multiply the availabilities. Parallel: 1 minus the product of the unavailabilities, which is valid only when failures are independent.
Availability and durability
Availability: can I reach the service now? Durability: is my data still there? A system can be unreachable for an hour and lose nothing, or stay up and lose data.
Active-passive and active-active
Active-passive: a standby takes over on failure. Simple, but failover takes time and the standby sits idle. Active-active: all nodes serve. There is no promotion step, but each node needs spare capacity and concurrent writes need conflict handling.
SLI, SLO and SLA
SLI: a measured ratio of good events. SLO: the internal target for it. SLA: a contract with customers that carries penalties, usually set looser than the SLO.
RTO and RPO
Recovery time objective: how long you may be down. Recovery point objective: how much recent data you may lose. Asynchronous replication means the recovery point is not zero.
Interview questions on this
- Your service calls five internal services, each with a 99.9% availability SLO. Product wants you to promise 99.95%. Can you?
- You run active-passive across two regions, and the primary region goes dark. Walk me through the failover and what can go wrong.
- Your service has a 99.9% monthly SLO and used its whole error budget in the first week. Product wants to ship a big feature next week. What do you do?