Sub topic 1
Availability and what the nines mean
Availability is the share of time a service is able to do its job. This chapter defines it, shows what each "nine" costs in downtime, and gives you the series and parallel formulas that the rest of the tutorial builds on.
Prerequisites
This chapter assumes you already know:
- Basic client-server architecture: a client sends requests and a server answers them.
- What a load balancer and DNS do, at a high level.
- Basic networking ideas such as timeouts and health checks.
You do not need probability training. The formulas use only multiplication and subtraction.
What availability measures
Availability is the fraction of a time window during which a service works correctly:
availability = uptime / (uptime + downtime)A service that is broken for 43 minutes in a 30-day month (43,200 minutes) has an availability of about 99.9%.
"Works correctly" needs a definition before the number means anything. Teams usually state it as a service level indicator (SLI), such as "a request succeeds with HTTP status below 500 and finishes in under 300 ms". A server that answers every request with an error is up in the sense that the process is running, but it is not available.
Two related terms appear throughout this tutorial:
- A service level objective (SLO) is the target you set for an SLI, for example "99.9% of requests succeed over 30 days".
- A service level agreement (SLA) is a contract that promises a level of service and usually specifies a penalty, such as credits, if the provider misses it.
An SLO is an internal goal. An SLA is a commitment to a customer. SLAs are normally set looser than the SLOs behind them, so you have room to miss your own goal without paying a penalty.
The nines and the downtime they allow
People describe availability by counting nines: "three nines" is 99.9%. Each extra nine cuts allowed downtime by a factor of ten.
| Availability | Common name | Downtime per year | Downtime per 30-day month |
|---|---|---|---|
| 99% | two nines | about 3.65 days | about 7.2 hours |
| 99.9% | three nines | about 8.76 hours | about 43 minutes |
| 99.99% | four nines | about 52.6 minutes | about 4.3 minutes |
| 99.999% | five nines | about 5.26 minutes | about 26 seconds |
You can compute any row yourself. The allowed downtime is (1 - availability) × period. For 99.95% over a 30-day month, that is 0.0005 × 43,200 minutes, or about 21.6 minutes.
def downtime_minutes(availability, period_minutes=30 * 24 * 60):
return (1.0 - availability) * period_minutes
for a in (0.99, 0.999, 0.9995, 0.9999, 0.99999):
print(f"{a:.5f} -> {downtime_minutes(a):8.2f} minutes per 30 days")The output shows how quickly the budget shrinks. At four nines, a single bad deployment that takes 5 minutes to roll back exceeds the whole month's allowance.
Error budgets
The allowed downtime is also called an error budget. If your SLO is 99.9% over 30 days, you have about 43 minutes of budget. Every outage, failed deploy, or maintenance window spends some of it. Teams use the remaining budget to decide whether to ship risky changes or to spend the time on reliability work.
What the number hides
A single availability figure leaves out several things you should ask about.
- Measurement window. 99.9% measured over a year allows one 8-hour outage. Measured per month, the same target allows only 43 minutes in each month. Shorter windows are stricter about long outages.
- Scheduled maintenance. Some SLAs exclude planned downtime. Whether yours does changes the real figure a user experiences.
- Partial failure. If 5% of requests fail for an hour, the service was not fully down, yet users noticed. Request-based SLIs (successful requests divided by total requests) capture this. Time-based measures often do not.
- Frequency versus duration. Ten 1-minute outages and one 10-minute outage give the same availability. Users and downstream systems may react very differently to each.
- Where you measure. A probe inside the data center can report 100% while users on the internet cannot connect. Measure as close to the user as practical.
Components in series
Most systems are chains of components. A request goes through DNS, a load balancer, an application server, and a database. If any one of them is down, the request fails. This is a series arrangement.
If the components fail independently, the system is available only when all of them are available. You multiply their availabilities:
A_series = A1 × A2 × ... × AnTwo components at 99% each give 0.99 × 0.99 = 0.9801, or 98.01%. The chain is worse than its weakest link, because every component adds its own chance of failure.
This has a practical consequence. A request path with ten dependencies, each at 99.9%, gives 0.999^10 ≈ 0.990, or about 99%. You started with three-nines parts and ended with a two-nines system.
Components in parallel
Redundancy changes the arrangement. If you run two copies of a component and either one can serve the request, the pair fails only when both are down at the same time. This is a parallel arrangement.
Work with the probability of failure, which is 1 - A:
A_parallel = 1 - (1 - A1) × (1 - A2) × ... × (1 - An)Two components at 99% each have a combined failure probability of 0.01 × 0.01 = 0.0001. Availability is 1 - 0.0001 = 0.9999, or 99.99%. Two two-nines parts have become one four-nines pair.
The code below implements both formulas.
def series(*availabilities):
result = 1.0
for a in availabilities:
result *= a
return result
def parallel(*availabilities):
all_down = 1.0
for a in availabilities:
all_down *= (1.0 - a)
return 1.0 - all_down
print(series(0.99, 0.99)) # about 0.9801
print(parallel(0.99, 0.99)) # about 0.9999Combining the two
Real designs mix both. You can compute a path by replacing each redundant group with its parallel availability, then multiplying the groups in series.
def series(*availabilities):
result = 1.0
for a in availabilities:
result *= a
return result
def parallel(*availabilities):
all_down = 1.0
for a in availabilities:
all_down *= (1.0 - a)
return 1.0 - all_down
load_balancer = parallel(0.999, 0.999)
app_tier = parallel(0.99, 0.99, 0.99)
database = 0.999 # a single instance, not redundant
total = series(load_balancer, app_tier, database)
print(f"{total:.6f}") # about 0.998999The result is about 99.9%. The redundant load balancer and application tier are each far better than the database, so the single database now sets the ceiling for the whole system. The calculation points directly at where the next investment should go.
Limits of the parallel formula
The parallel formula gives striking numbers, and they are often too optimistic. Know the assumptions before you trust them.
- Independence. The formula assumes failures are unrelated. If both copies share a power feed, a rack, a deployment pipeline, or a software bug, one cause takes both down and the real availability is far below the calculated value. Later chapters cover fault domains for this reason.
- Failover is not instant. The formula treats a spare as taking over perfectly. In practice detection and switching take time, and requests during that gap fail. The real figure includes this switching time.
- Capacity. If two servers are each needed to carry peak load, losing one leaves too little capacity. The pair is then not redundant for that load, and the calculation overstates it.
- The redundancy mechanism itself can fail. A load balancer, health checker, or failover controller is a component in series with the things it protects. A poorly built one can reduce availability.
- Diminishing returns. Going from one to two copies gives the largest gain. A third copy adds less and costs the same as the second. Beyond a point, shared causes dominate and extra copies change little.
Choosing a target
Higher availability costs more in hardware, engineering effort, and operational complexity. Pick a target from the cost of downtime and what users need, not from a desire for more nines.
- Estimate what an hour of downtime costs in revenue, support load, and trust.
- Compare that with the cost of the extra redundancy needed for the next nine.
- Check the dependencies. Your service cannot be more available than the components in series with it that you do not control, such as a cloud provider or payment processor.
- Set the SLO a little tighter than the promise you make to customers.
Many internal tools do well at two or three nines. Five nines usually means designing out manual steps, because a human responding to a page often cannot fix a problem within the allowed seconds.
Key points
- Availability is uptime divided by total time, judged against a clear definition of "working".
- Each extra nine allows one tenth of the downtime.
- Series components multiply availability and make the system worse than any part.
- Parallel components multiply failure probabilities and make the system better than any part, if failures are independent.
- The least redundant component in a path usually sets the system's ceiling.
Exercise
A request path has three components in series: a load balancer at 99.99%, an application tier at 99.9%, and a single database at 99.5%. You add a second, independent database with 99.5% availability, so that either can serve the request. What is the availability of the path before and after, and which component limits the result afterward?
Show answer
Before: 0.9999 × 0.999 × 0.995 ≈ 0.9939, or about 99.39%. After: the database pair is 1 − (0.005 × 0.005) = 0.999975. The path is 0.9999 × 0.999 × 0.999975 ≈ 0.99888, or about 99.89%. The application tier at 99.9% now limits the result, since it is the least available part left in the series. This assumes the two databases fail independently and that failover is instant.
Exercise
An SLO of 99.95% is measured over a 30-day month. How many minutes of downtime does it allow, and why might a single 30-minute outage be a problem even though the total looks small?
Show answer
Allowed downtime is 0.0005 × 43,200 minutes = 21.6 minutes. A 30-minute outage exceeds the whole monthly budget by about 8 minutes, so the SLO is missed with one incident.