Sub topic 5
MTBF, MTTR, and why recovery speed matters
This chapter assumes you know what availability is, how the nines map to downtime budgets, and how to read short Python snippets. Here you will connect availability to two measurable quantities: how often a service fails and how long it takes to recover.
The two quantities
Two averages describe the failure behavior of a component over a long period:
- MTBF (mean time between failures) is the average time a component runs correctly from one failure to the next.
- MTTR (mean time to repair, or recover) is the average time from the start of a failure until the service works again.
One cycle of operation is a stretch of working time followed by a stretch of repair. The component is available for the working part of that cycle, so availability is the working part divided by the whole cycle:
availability = MTBF / (MTBF + MTTR)
def availability_from_mtbf(mtbf_hours, mttr_hours):
return mtbf_hours / (mtbf_hours + mttr_hours)
print(availability_from_mtbf(1000, 1)) # about 0.999001
print(availability_from_mtbf(1000, 0.1)) # about 0.9999A service that fails once every 1000 hours and takes 1 hour to fix reaches about three nines. If the same service is fixed in 6 minutes (0.1 hours), it reaches about four nines. Failures are exactly as frequent in both cases.
Two ways to gain a nine
When MTTR is small compared with MTBF, the unavailable fraction is approximately MTTR / MTBF. That gives two levers:
- Make failures ten times rarer by raising MTBF tenfold.
- Make recovery ten times faster by cutting MTTR to a tenth.
Both cut the unavailable fraction by about ten, which is one extra nine. They differ in how hard they are to achieve.
| Lever | What you do | Typical difficulty |
|---|---|---|
| Raise MTBF | Better hardware, more testing, simpler code, fewer risky changes | Gains flatten out. Software always has unknown bugs. |
| Cut MTTR | Faster detection, automatic failover, quick rollback, runbooks | Mostly engineering and process work, and it applies to failures you did not predict. |
Raising MTBF only helps against failures you have anticipated. Cutting MTTR helps against every failure, including new ones. This is why many teams invest in monitoring, automated rollback, and practiced incident response before they chase ever-rarer failures.
Where MTTR goes
MTTR is a sum of phases, and the early ones are often the largest:
- Detection: time until someone or something notices the failure.
- Diagnosis: time to find the cause or at least a safe mitigation.
- Mitigation: time to act, for example by rolling back, failing over, or restarting.
- Verification: time to confirm that users are served correctly again.
A failure that takes 20 minutes to notice cannot fit into a four-nines budget of about 4.3 minutes per month, however fast the fix is. Alerting on user-facing symptoms rather than on internal causes shortens detection.
Limits of the formula
- MTBF and MTTR are averages. One 4-hour outage and many short ones can share the same mean but affect your budget very differently. Look at the distribution, not only the mean.
- The formula assumes long-run steady behavior. With few failures in your data, the estimates are noisy.
- Hardware vendors' MTBF figures describe parts, not services. A service with a long MTBF per server can still fail often because of deployments, configuration, and dependencies.
You can check that figure with the formula: one year is 8760 hours, repair is 72 hours, so 8760 / (8760 + 72) is about 0.9918.
Exercise
A service has an MTBF of 500 hours and an MTTR of 2 hours. (a) What is its availability? (b) Which gives a larger gain: doubling MTBF to 1000 hours, or cutting MTTR to 1 hour?
Show answer
(a) 500 / (500 + 2) is about 0.99602, or 99.60%. (b) Doubling MTBF gives 1000 / 1002, about 0.99800. Cutting MTTR to 1 hour gives 500 / 501, about 0.99800. Both halve the unavailable fraction from about 0.40% to about 0.20%, so the gains are equal here. The difference is in effort: halving MTTR usually costs less than doubling the time between failures, and it also helps with failures you have not seen yet.