Sub topic 1
What Availability Means
Prerequisites
This chapter assumes you know the following:
- How a client-server or web service works at a basic level: a client sends a request, a server returns a response.
- Percentages, and multiplying simple probabilities.
- How to read short Python snippets.
You do not need prior experience with SLOs or reliability engineering. Later chapters build on the definitions given here.
Why start with a definition
"Is the service up?" sounds like a yes-or-no question. In practice, a service can answer some requests and fail others. It can be reachable but too slow to use. It can return fast responses that are wrong. A team that has not agreed on a definition will argue about these cases during an incident, when the argument is most expensive.
This chapter gives a working definition of availability. It then separates availability from two terms that are often confused with it, reliability and durability. It ends with the ideas the rest of the tutorial turns into numbers.
A working definition
Availability is the fraction of time, or the fraction of requests, for which a service works correctly and is ready to be used.
Written as a formula:
availability = good time / total time
availability = successful requests / total valid requestsBoth forms give a number between 0 and 1, usually written as a percentage. A service that is available 99.9% of the time is unavailable 0.1% of the time. Chapter 2 explains the shorthand "three nines" for that figure. Chapter 4 compares the two forms of measurement.
Three words in the definition do most of the work.
- Fraction. Availability is a ratio over a period, not a yes/no state. You can only state it for a window, such as "99.95% over the last 30 days."
- Correctly. A response counts only if it is right enough for the user. An HTTP 200 with an empty page, or a response after a 30-second wait, is not a success.
- Ready to be used. The service must accept work when the user needs it. A system that is healthy but sitting behind a broken load balancer is not available to anyone.
A minimal calculation
Suppose a service handled 2,000,000 valid requests in a day and 1,400 of them failed.
def availability(successful, total):
return successful / total
total = 2_000_000
failed = 1_400
print(f"{availability(total - failed, total):.4%}")
# 99.9300%The service was 99.93% available for that day, measured by requests. If the same failures all happened during one 20-minute stretch, a time-based measure would give a different number. Chapter 4 covers why the two disagree.
Availability, reliability, and durability
These three words are related, and people swap them freely. Keep them apart, because each one answers a different question.
| Term | Question it answers | Typical measure |
|---|---|---|
| Availability | Can users use the service right now? | Fraction of time or requests that succeed |
| Reliability | Does the service keep working correctly over time without failing? | Probability of no failure over a period, or mean time between failures |
| Durability | Is stored data still there and intact later? | Probability that a stored object is not lost over a period |
Availability versus reliability
Reliability is about how often failures happen. Availability also depends on how long each failure lasts. Two services can fail at very different rates and still have the same availability.
- Service A fails once a month and takes 43 minutes to recover.
- Service B fails 43 times a month and takes 1 minute to recover each time.
Both lose about 43 minutes a month, so both sit near 99.9%. Service B is far less reliable. Users of B see 43 separate failures. Service A is more reliable but has a long outage whenever it does fail. Which one is better depends on what the users do. A nightly batch job might tolerate B easily and be hurt badly by A. A checkout page might be the opposite.
The relationship is made exact in Chapter 5, where availability is expressed with mean time between failures (MTBF) and mean time to repair (MTTR).
Availability versus durability
Durability concerns data that must not be lost. Availability concerns whether you can reach it.
An object store can be briefly unavailable, for example during a network partition, and lose nothing. Its durability is unaffected. The opposite case is worse: a store can answer every request quickly and still have silently corrupted a disk. Availability looks perfect while durability has failed.
Because of this, the two properties often need different designs. Keeping many copies of data on different disks raises durability. Keeping a copy that can be read and written right now, during a failure, raises availability. Some designs give up a little of one to get more of the other. Chapter 10 returns to this when it discusses failure domains.
What "correctly" means in practice
The word "correctly" is where most disagreements start. There are four common failure shapes, and a definition should say how each one is treated.
- Hard failure. The service is unreachable or returns an error. Everyone agrees this counts as down.
- Slow response. The service answers, but after a time the user will not wait. Most teams set a latency threshold and count requests slower than it as failures.
- Wrong response. The service returns a success status with incorrect content. This is hard to detect automatically, so it is often missing from availability numbers even though users experience it as an outage.
- Partial failure. Part of the service works and part does not, or it works for some users and not others. Chapter 11 covers how to count these.
A practical rule is to write the definition from the user's point of view. Ask "what would a user call broken?" and make sure the measurement would catch it.
Who counts as the user
The user might be a person with a browser, a mobile app, or another service calling your API. Each sees different failures. A service can be available to its own health check and unavailable to real traffic. For that reason, measure at a point as close to the user as you can, such as the load balancer or the client, and not only on the server that is doing the work.
The state model
At its simplest, a service moves between a working state and a failed state. Failures move it down, and repairs bring it back.
The time spent in Working before each failure is the time to failure. The time spent in Failed before each repair is the time to repair. Availability is the long-run share of time in Working. This picture explains why there are two ways to improve availability:
- Make failures less frequent, so the service stays in Working longer.
- Make repairs faster, so the service stays in Failed for less time.
Chapter 5 turns these two levers into a formula. For now, notice that most teams get more gain from the second lever than they expect.
Where availability sits among related ideas
Availability is a property of a service as users experience it. It depends on several things that you control, and on several that you do not.
The third input is easy to forget. Changing what counts as a failure changes the number without changing the service. A team that excludes slow responses will report a higher figure than a team that includes them, and both can be honest. This is why a figure such as "99.9%" means little until you know the window, the measurement point, and the definition of success.
Common mistakes
- Reporting a number without a window. "99.9% available" has no meaning until you say over what period. A single bad hour is 0.14% of a month and 0.01% of a year.
- Treating a health check as the truth. A passing health check shows that one endpoint responded. It does not show that users can complete their tasks.
- Mixing up uptime and availability. Uptime usually means the process was running. A running process that returns errors is up but not available.
- Counting only full outages. If a service fails 5% of requests for a whole day, a binary up/down view reports zero downtime. A request-based view reports 95% availability for that day.
- Assuming 100% is a sensible target. Every component fails eventually, and every change carries risk. Chapter 13 shows why each extra nine costs more than the last, and why 100% is rarely worth pursuing.
A short example of the last point about partial failure
The snippet below compares a binary view and a request-based view of the same day. In the binary view, a minute counts as down only if every request in it failed. In the request-based view, each failed request counts.
# 1,440 minutes in a day, 100 requests per minute.
# Every minute, 5 of the 100 requests fail.
minutes = 1440
requests_per_minute = 100
failed_per_minute = 5
# Binary view: a minute is down only if all requests failed.
down_minutes = sum(1 for _ in range(minutes) if failed_per_minute == requests_per_minute)
binary_availability = (minutes - down_minutes) / minutes
# Request-based view.
total = minutes * requests_per_minute
failed = minutes * failed_per_minute
request_availability = (total - failed) / total
print(f"binary: {binary_availability:.2%}")
print(f"request: {request_availability:.2%}")
# binary: 100.00%
# request: 95.00%One in twenty users had a bad day, and the binary view did not register it.
What comes next
The rest of the tutorial builds on this definition in order:
- Chapters 2 and 3 introduce the nines and convert them into a downtime budget.
- Chapter 4 compares time-based and request-based measurement.
- Chapter 5 links availability to MTBF and MTTR.
- Chapters 6 and 7 define SLIs, SLOs, SLAs, and error budgets.
- Chapters 8 to 10 show how dependencies, redundancy, and correlated failures change the availability of a whole system.
- Chapters 11 to 13 cover planned maintenance, design patterns, and the cost of each extra nine.
Exercise
A service handled 50,000,000 valid requests in a 30-day month. Of these, 20,000 returned errors and 30,000 took longer than the agreed 2-second limit, which the team counts as failures. What is the request-based availability, and why can a service with this figure still be less reliable than one with a lower figure?
Show answer
Failures are 20,000 + 30,000 = 50,000. Successes are 50,000,000 - 50,000 = 49,950,000. Availability is 49,950,000 / 50,000,000 = 0.999, or 99.9%. Availability counts how much work failed, not how often failures happened or how long each lasted. A service with 99.9% could have one long outage, or thousands of short ones. If the 50,000 failures came as many separate incidents, users saw many interruptions, so that service is less reliable than one that reached, say, 99.8% through a single outage.
Exercise
A storage service answers every read request within 50 ms for a full year, but a firmware bug silently corrupts 0.01% of stored objects. Describe its availability and its durability.
Show answer
Its availability is very high, close to 100%, because every request succeeds quickly. Its durability is poor, because stored data has been lost or damaged. This shows the two are separate properties: a service can be fully available while failing to keep data intact.