Sub topic 1
Availability and What the Nines Mean
Prerequisites
This chapter assumes you know basic client-server architecture. It also assumes you have a high-level familiarity with load balancers and DNS, and that you understand timeouts and health checks. No math beyond multiplication is needed.
What availability measures
Availability is the fraction of time a service is able to do its job. You usually write it as a percentage. If a service is up for 99.9% of a month, it is unavailable for the other 0.1%.
The common formula is:
availability = uptime / (uptime + downtime)
Teams often speak of "the nines". Each extra nine cuts the allowed downtime by a factor of ten.
| Availability | 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 |
Components in series
Components are in series when a request needs all of them to succeed. A web server that needs a database is one example. If either fails, the request fails.
To find the combined availability, multiply the individual values. Two components at 99% each give 0.99 × 0.99 = 0.9801, or 98.01%. The chain is less available than its weakest link, and every extra dependency lowers the total.
Components in parallel
Components are in parallel when any one of them can serve the request. The system is down only when all of them are down at once. So you multiply the failure probabilities instead.
For two components at 99%, each is down 1% of the time. Both are down together 0.01 × 0.01 = 0.0001 of the time. Availability is 1 − 0.0001 = 0.9999, or 99.99%.
This is why redundancy works. Adding a second copy turns two nines into four.
Calculating it in code
The two rules translate directly into Python.
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.9999You can combine the two. Suppose a service needs a load balancer at 99.99% in front of two app servers at 99% each:
lb = 0.9999
app_tier = parallel(0.99, 0.99)
print(series(lb, app_tier)) # about 0.9998The result is about 99.98%. The load balancer is now the main limit, and adding a third app server would barely change the total.
Common errors
- Assuming independence. The parallel formula holds only if copies fail independently. Two servers in the same rack share power and a network switch, so they can fail together. A later chapter on fault domains covers this.
- Ignoring dependencies. A redundant app tier still sits in series with a single database, DNS provider, or deploy pipeline.
- Counting only hardware. Bad deploys, expired certificates, and misconfiguration cause many outages. The formula does not capture them.
- Treating the result as a promise. The numbers are estimates built on assumed availabilities. Measure real uptime to check them.
Exercise
A request passes through a load balancer (99.99%), then an app server pair in parallel (99% each), then a single database (99.9%). What is the overall availability, to four decimal places?
Show answer
The app tier in parallel is 1 − (0.01 × 0.01) = 0.9999. In series: 0.9999 × 0.9999 × 0.999 = about 0.9988, or 99.88%. The single database is the weakest link, so adding a replica there would help most.
Exercise
Why does adding a third parallel server to a tier already at 99.99% give little benefit if the tier sits in series with a 99.9% database?
Show answer
The database caps the total. The overall availability cannot exceed 99.9%, and moving the tier from 99.99% to 99.9999% changes the product by only a few hundredths of a percent.