Sub topic 4
Measuring availability: time-based versus request-based
This chapter assumes you know the definition of availability and how to read the nines. You should also be comfortable with percentages and short Python snippets. It covers the two standard ways to turn raw monitoring data into an availability number, and why they can disagree.
Two ways to count
A time-based measurement asks how much of the period the service was up. You divide the minutes of "good" time by the total minutes in the window.
A request-based measurement asks how many requests succeeded. You divide successful requests by all valid requests in the window.
Both give a fraction between 0 and 1, and both are usually quoted as a percentage. They answer different questions, so the same incident can score differently under each.
A worked comparison
Take a 30-day window with 10 million requests. A 20-minute outage happens. The time-based result is the same wherever the outage falls, but the request-based result depends on how much traffic arrived during it.
def time_based(total_minutes, down_minutes):
return 1 - down_minutes / total_minutes
def request_based(total_requests, failed_requests):
return 1 - failed_requests / total_requests
window_minutes = 30 * 24 * 60 # 43,200
total_requests = 10_000_000
# The same 20-minute outage, at two different times of day.
off_peak_failures = 20 * 100 # 100 requests per minute at 3 a.m.
peak_failures = 20 * 1_000 # 1,000 requests per minute at noon
print(f"time-based: {time_based(window_minutes, 20):.3%}")
print(f"request-based, 3 a.m.: {request_based(total_requests, off_peak_failures):.3%}")
print(f"request-based, noon: {request_based(total_requests, peak_failures):.3%}")
# time-based: 99.954%
# request-based, 3 a.m.: 99.980%
# request-based, noon: 99.800%The time-based figure treats both outages as equal. The request-based figure shows that the noon outage hurt ten times as many users.
What counts as "down" in time-based measurement
Real failures are rarely all or nothing. Time-based measurement needs a rule that decides whether a given minute is good or bad. A common rule is to mark a minute as down if its error rate is above a threshold, such as 1%, or if its latency is above a limit.
The threshold choice matters. A service that fails 0.5% of requests all month never has a "down" minute under a 1% rule, yet it would fail a request-based target of 99.9%.
What counts as a request
Request-based measurement also needs rules:
- Count only valid requests. Malformed requests that deserve a 4xx response are usually excluded, since the service behaved correctly.
- Count server-side failures (5xx, timeouts) as bad.
- Decide whether slow responses are bad. A response that arrives after the client gave up is a failure in practice.
- Measure as close to the user as you can. A load balancer log misses requests that never reached it.
Choosing between them
The two methods compare like this:
| Aspect | Time-based | Request-based |
|---|---|---|
| Unit | Minutes of good time | Successful requests |
| Weights busy periods more | No | Yes |
| Handles partial failures | Needs a threshold rule | Naturally |
| Works with no traffic | Yes | Undefined with zero requests |
| Common use | Contracts, simple services | Internal targets, high-traffic APIs |
Request-based measurement is usually the better fit for services with uneven traffic, because it matches what users experienced. Time-based measurement is easier to explain to customers and to write into contracts. Many teams track both and use request-based figures for engineering decisions.
Common errors
- Comparing a time-based target with a request-based result. The numbers are not interchangeable.
- Averaging per-minute percentages instead of summing requests first. A quiet minute with one failed request would count as much as a busy minute with thousands.
- Counting only total outages and ignoring degraded periods.
- Leaving the measurement window unstated. Availability over 30 days and over a calendar quarter are different numbers.
Exercise
A service handled 50,000,000 requests in a month and 25,000 of them failed with server errors. A second service was fully unavailable for 10 minutes in a 43,200-minute month. Which one has the higher availability, and what are the two values?
Show answer
The first service has request-based availability of 1 - 25,000 / 50,000,000 = 0.9995, or 99.95%. The second has time-based availability of 1 - 10 / 43,200 ≈ 0.99977, or about 99.977%. The second is higher, though the two figures use different methods, so the comparison only holds if you accept that difference.