Non-functional targets you can test
Rewrite "fast, reliable and scalable" as targets you can test: latency percentiles, availability as a downtime budget, durability as a recovery point, and consistency chosen feature by feature, with SLI, SLO and SLA defined.
Contentsand lesson path
On this page
- Why it matters
- The five parts of a testable target
- Latency: percentiles, not averages
- Availability and its nines
- Durability and consistency, feature by feature
- Check your understanding
- Apply it
- Review prompt
Lessons of Requirements & Estimation
- From prompt to requirements: users, use cases and non-goals Concept · 20 min
- Non-functional targets you can test Concept · 15 min
- Numbers to carry in your head: latency, throughput, powers of two Concept · 20 min
- Estimating a photo-sharing service end to end Worked example · 30 min
- A repeatable design sequence Concept · 15 min
- Estimation drill Knowledge check · 10 questions
What you will learn
- Turn a vague prompt into prioritized functional requirements, explicit non-goals and measurable non-functional targets (latency percentiles, availability, durability, consistency).
01. Why it matters
Ask anyone what a system should be like and you hear the same words: fast, scalable, reliable, secure. Nobody disagrees, and that is the problem. A word nobody can disagree with cannot be tested, so it cannot guide a design or settle an argument. Is a 900 ms checkout fast? For whom, how often, and under what load?
A non-functional requirement (NFR) describes how well the system does its job rather than what it does: speed, availability, durability, consistency, security, cost. This lesson shows how to write NFRs as numbers you can test, using the ticket booking service from the previous lesson. Along the way you will meet percentiles, the nines of availability, and the difference between an SLI, an SLO and an SLA.
02. The five parts of a testable target
A testable target has five parts. Leave one out and two people can measure the same system and reach different verdicts.
- What is measured, and where: the time from the load balancer receiving a seat-hold request to it sending the response.
- A statistic, usually a percentile (explained below) rather than an average.
- A threshold: under 300 ms.
- The conditions in which the target applies, such as at up to 2,000 hold requests per second.
- A window, the period over which you judge it, such as each 5 minutes or 30 days.
Put together: 99% of seat-hold requests complete in under 300 ms, measured at the load balancer over each 5-minute window, at up to 2,000 requests per second. An engineer can turn that into a load test and a dashboard, and a reviewer can check whether a design can meet it.
Site reliability engineering (SRE) gives these pieces standard names. A service level indicator (SLI) is the measurement itself, for example the share of hold requests answered in under 300 ms. A service level objective (SLO) is the target for that indicator over a window: 99% over 5 minutes. A service level agreement (SLA) is a contract with customers that says what happens, often a refund, if a promised level is missed. SLAs are usually looser than the internal SLOs, so the team gets a warning before the contract is breached. The Observability skill shows how to measure SLIs and alert on them: SLOs, probes and burn-rate alerts.
03. Latency: percentiles, not averages
Latency is how long one operation takes. Requests take different times, so you describe the whole distribution. The p99 (99th percentile) is the value that 99% of requests are at or below; p50 is the median, the middle value. The script below computes these for 100 made-up request timings, plus two other numbers this lesson needs. It uses only the Python 3.12 standard library.
"""Three calculations behind non-functional targets (Python 3.12, stdlib only)."""
import math
MINUTES_PER_30_DAYS = 30 * 24 * 60 # 43,200 minutes
MINUTES_PER_365_DAYS = 365 * 24 * 60 # 525,600 minutes
def nearest_rank(values: list[int], p: int) -> int:
"""The p-th percentile: the smallest value with at least p% of values <= it."""
ordered = sorted(values)
rank = math.ceil(p / 100 * len(ordered))
return ordered[rank - 1]
print("1) Downtime budget for an availability target")
for target in (99.0, 99.9, 99.95, 99.99, 99.999):
allowed = 1 - target / 100
month = allowed * MINUTES_PER_30_DAYS
year = allowed * MINUTES_PER_365_DAYS
print(f" {target:>6}%: {month:7.2f} min per 30 days, {year:7.1f} min per year")
print("2) Mean versus percentiles for 100 requests")
latencies_ms = [30] * 95 + [260] * 4 + [1800]
mean = sum(latencies_ms) / len(latencies_ms)
print(f" mean: {mean:.0f} ms")
for p in (50, 95, 99):
print(f" p{p}: {nearest_rank(latencies_ms, p)} ms")
print(f" max: {max(latencies_ms)} ms")
print("3) Requests that wait for at least one slow call (each call slow 1%)")
for calls in (1, 10, 50):
share = 1 - 0.99**calls
print(f" fan-out to {calls:>2} calls: {share:.1%} of requests")python3.12 nfr_math.py1) Downtime budget for an availability target
99.0%: 432.00 min per 30 days, 5256.0 min per year
99.9%: 43.20 min per 30 days, 525.6 min per year
99.95%: 21.60 min per 30 days, 262.8 min per year
99.99%: 4.32 min per 30 days, 52.6 min per year
99.999%: 0.43 min per 30 days, 5.3 min per year
2) Mean versus percentiles for 100 requests
mean: 57 ms
p50: 30 ms
p95: 30 ms
p99: 260 ms
max: 1800 ms
3) Requests that wait for at least one slow call (each call slow 1%)
fan-out to 1 calls: 1.0% of requests
fan-out to 10 calls: 9.6% of requests
fan-out to 50 calls: 39.5% of requestsLook at part 2. The mean of 57 ms describes no real request: 95 requests took 30 ms and five took far longer. The p95 is still 30 ms; only the p99 shows the slow group. The percentile you choose decides which users your target protects, which is why SRE practice prefers percentiles to averages. Tools also compute percentiles in slightly different ways (this script uses the simple nearest rank method), so say which one you use when numbers are close to a threshold.
Part 3 shows why the slow tail matters more as systems grow. If one page waits for 50 backend calls made in parallel, and each call is slow 1% of the time independently of the others, about 40% of pages wait for at least one slow call. Jeffrey Dean and Luiz André Barroso described this effect in The Tail at Scale (2013): in systems that fan out, rare slowness in the parts becomes common slowness in the whole. A target for a page therefore implies tighter targets for each part it calls.
04. Availability and its nines
Availability is the share of time, or of requests, in which the service works. It is often written in nines: 99.9% is three nines. Part 1 of the output turns each target into a downtime budget, which SRE practice calls the error budget (the failure an SLO allows, 1 minus the target), and which is easier to reason about: 99.9% allows about 43 minutes of failure in 30 days, and 99.99% about 4 minutes. Each extra nine cuts the budget tenfold and usually costs much more to reach: redundant servers in more places, automatic failover, and slower, more careful releases.
Two choices make an availability target meaningful. The first is what counts as failure. A time-based SLI counts the minutes in which a health check failed; a request-based SLI counts the share of valid requests that succeeded, which Google's SRE book calls yield. A ticketing site gets most of its traffic in the minutes after a sale opens, so a request-based SLI is more honest there: twenty broken minutes during an on-sale can hurt more fans than a broken quiet day. The second choice is the window and its exclusions: 30 days or a calendar quarter, and whether announced maintenance counts.
Availability also multiplies along a chain. If every request needs four services in sequence, and each is up 99.95% of the time independently, the chain is up only about 99.8% of the time (0.9995 to the power 4). You cannot promise more than your dependencies allow unless you add redundancy or let the feature degrade gracefully when a dependency fails.
05. Durability and consistency, feature by feature
Durability means not losing data that the system said it had stored. It is not the same as availability. A storage service can be unreachable for an hour and lose nothing; another can stay up while a disk failure destroys the only copy of yesterday's uploads. Durability targets are written as a probability of loss over a period, or as a recovery point objective (RPO): how much recent data you could lose in a disaster, such as at most 15 minutes of analytics events. A confirmed ticket purchase usually needs an RPO of zero: before the fan sees confirmed, the order is already stored in more than one place, for example in two availability zones (separate data centres within one cloud region).
Consistency describes what readers see after a write. With strong consistency, every read that starts after a write has finished sees that write. With eventual consistency, readers may see older data for a while, but all copies agree once writes stop. Read-your-writes is a middle ground: each user always sees their own changes, while other users may lag behind.
Choose consistency per feature, because its price differs. In the ticketing service, seat inventory must be strongly consistent, or the invariant one seat, one fan breaks. The list of upcoming events can be a minute stale: nobody is harmed if a new event appears 60 seconds late. After paying, a fan must see their own ticket at once (read-your-writes), even if the organiser's sales report lags by a few minutes. Separate targets let the design use cheap cached reads where staleness is harmless, and costly coordinated writes only where the invariant needs them.
Latency 99% of seat holds < 300 ms at the load balancer, per 5-minute window,
at up to 2,000 holds/s. 99% of event pages < 800 ms.
Availability 99.9% of valid checkout requests succeed, per 30-day window;
maintenance announced 7 days ahead is excluded.
Durability a confirmed order is stored in 2 zones before the fan sees it
(RPO 0 for orders); analytics events RPO 15 minutes.
Consistency seat inventory: strong. Event list: up to 60 s stale.
My tickets: read-your-writes.
Load on-sale peak: assume 2,000 holds/s for 15 minutes (to confirm).06. Check your understanding
07. Apply it
Return to your three practice pages (paste service, ride-hailing location service, metrics ingestion pipeline) and add a block of non-functional targets to each, in the shape of the ticketing example:
- One latency target with all five parts: what and where, percentile, threshold, load, window.
- One availability target with a request-based SLI, a window and any exclusions.
- One durability target, as an RPO or as a statement of what must be stored before you acknowledge a write.
- Consistency for at least two features of the same system that need different levels, each with a one-line reason.
Mark every number that rests on an assumption, such as a load figure you have not confirmed. Lesson 4 checks some of those numbers with estimates.
08. Review prompt
Without looking back, answer in your own words:
- What are the five parts of a testable target? Write one for a login endpoint.
- Why can the mean latency look healthy while users complain, and what does p99 tell you that p50 does not?
- How much downtime do 99.9% and 99.99% allow in 30 days, and why might a request-based SLI be fairer than a time-based one?
- Give one example of a durability failure that is not an availability failure, and one feature that can safely be eventually consistent.
References
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
10 questions · about 8 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.