Nonfunctional Requirements

One slow backend call in a hundred sounds rare. A page that waits for 20 calls meets a slow one on 18.2% of loads, and the average page time never shows it.

Drag the number of backend calls each page makes, and watch the red dots: pages slower than the 100 ms target. Then we turn "fast", "reliable", "scalable" and "maintainable" into numbers, one at a time.

You need a little Python and what a probability is. We build the rest from zero.

Fan one page out to many calls

20

Illustrative model. A normal call takes about 10 ms; a slow call takes 120 ms or more. A page waits for its slowest call. The share of slow pages comes from Chapter 3's formula; the mean, median and p99 come from this run of 400 pages.

Chapter 0

A Wish Is Not a Requirement

Put a number on "fast" and "reliable", and the right design falls out

A manager asks for a checkout service that is "fast and reliable". One engineer proposes one big server. Another proposes twenty servers in two data centres. Who is right? Nobody can say, because nobody said how fast, how reliable, or for how many customers.

A functional requirement says what the system does: take an order, show a timeline. A nonfunctional requirement says how well it does it: how quickly, how often it is up, how much load it carries, how easy it is to run and change. "Fast" is a wish. "99% of checkouts answer in under 200 ms at 5,000 requests a second" is a requirement.

Build without a number, then meet the load

Each square is one server. Warm is busy, pink is paid for but idle, and a red bar is requests dropped. Drag the real peak load.

5,000 req/s

Illustrative: each server handles 1,000 requests a second. "Sized to a number" buys enough servers to stay 70% busy at the stated peak; Chapter 7 derives that rule.

At a peak of 5,000 requests a second, the one big server handles 2,000 and drops 3,000: 60% of customers fail. The fleet of 20 is 25% busy, so 15 servers' worth of capacity is paid for and idle. The design sized to the number needs 8 servers, each 62.5% busy. Only the number could tell you that.

This lesson follows Chapter 2 of Designing Data-Intensive Applications, 2nd edition, by Martin Kleppmann and Chris Riccomini (O'Reilly, 2026). The chapter opens with a social network's home timeline, then defines performance, reliability, scalability and maintainability. We explain the ideas in our own words, with our own examples and numbers. Chapter 1 covered the big architecture trades.

Failure. Symptom: the launch goes down at the first traffic spike. Measure: the peak load nobody wrote down, against the capacity nobody tested. Cause: the requirement was "it should scale". Fix: write the peak request rate, the latency target and the uptime target before any design.

  1. Timelines: pay for fan-out when you write, or when you read.
  2. Percentiles: describe response time by its spread, not its mean.
  3. The tail: why fan-out turns rare slow calls into common slow pages. The hero lives here.
  4. Budgets and nines: an uptime target as minutes you may spend.
  5. Hardware faults: in a big fleet, a disk dies every day.
  6. Redundancy: copies help, unless one fault hits them all.
  7. Scalability: describe load, then size the workers.
  8. Maintainability: repair time is part of uptime.
  9. The showcase: write a requirement sheet and meet it.
  10. The field guide: numbers, checklist, code and links.
A founder says "our API must be reliable". What should you ask first?

Chapter 1

Pay for Fan-Out When You Write, or When You Read

Count the work behind one home timeline, and see where a celebrity breaks the plan

A social network shows each user a home timeline: the recent posts of everyone they follow. One post fans out to many readers, and one timeline gathers posts from many authors. Someone must do that gathering. The question is when.

Fan-out on read (pull) builds the timeline when the user opens it: look up the latest posts of each account they follow and merge them. Fan-out on write (push) does the work when someone posts: insert the post into a stored timeline for each follower. Reading is then one lookup. Each stored timeline is derived data, a cache of the merge.

Both cost the same shape of work. Call the rate of events that trigger it R, and the number of items each event touches k, the fan-out. The work per second is C.

Say it aloud

C equals R times k.

C
C the work per second: post lookups for pull, timeline inserts for push.
R
R the rate of trigger events per second: timeline views for pull, new posts for push.
k
k the fan-out: accounts followed (pull) or followers (push). Across a whole network the two averages are equal, because every follow has one follower and one followee.
In plain words

Take how often the work is triggered, R. Multiply by how many items each trigger touches, k. That is C. Choose the side where R is smaller.

With numbers

With made-up numbers: 300,000 timeline views a second, 6,000 posts a second, and k = 200 on average. Pull: C = 300,000 × 200 = 60 million lookups a second. Push: C = 6,000 × 200 = 1.2 million inserts a second, 50 times less.

Choose when the timeline is built

Blue dots are posts in flight, teal boxes are stored timelines, and the bars use a log scale. Pick a strategy, change how often people read, then let a celebrity post.

50

Illustrative network: 6,000 posts a second, 200 follows each, and in hybrid each user follows 2 celebrity accounts that are pulled at read time. Write capacity is sized to 1.2 million inserts a second.

Push wins while views outnumber posts, which is the common case. Its weak point is the celebrity: one post from an account with 50 million followers is 50 million inserts, about 42 seconds of the whole write capacity. The hybrid answer pushes normal accounts and pulls the few huge ones when a reader opens the page.

Failure. Symptom: followers see a celebrity's post minutes late, and other posts queue behind it. Measure: the insert backlog right after one large account posts. Cause: push fan-out of one post to tens of millions of timelines. Fix: pull accounts above a follower threshold at read time.

Views are 50 times as common as posts, and each account follows 200 others on average. Which strategy does less work per second for normal accounts?

Chapter 2

Describe Response Time With Percentiles

Sort the samples, read the value at a rank, and stop trusting the mean

Response time is what the client measures: from sending a request to getting the answer. Service time is the part the server spends working on it. The rest is waiting, in queues and on the network. Throughput is how many requests the system finishes each second.

Send the same request a thousand times and you get a thousand response times. A garbage-collection pause or a lost packet makes some slow. So one number must say which part of the spread you mean.

The mean is a poor choice. Take 1,000 requests: 950 take 5 ms, 49 take 50 ms and 1 takes 5,000 ms. The mean is 12.2 ms, a time that no request had.

A percentile says instead: p percent of requests were at least this fast. The median is p50. The tail is p99 and above.

To find it, sort the N samples from fastest to slowest. Call the percentage you want p. The rank you read is r, and the value there is the percentile.

Say it aloud

r equals the ceiling of p over 100 times N, and the percentile is x-sub-r, the r-th smallest sample.

r
r the rank: which sample to read after sorting, counting from 1.
⌈ ⌉
the ceiling of round up to the next whole number, so the rank is a real position.
p
p the percentile you want: 50 for the median, 99 for p99.
N
N the number of samples, here 1,000 requests.
x(r)
x-sub-r the r-th smallest response time in the sorted list.
In plain words

Sort the N response times. Multiply N by p over 100 and round up to get the rank r. Read the sample at rank r. This is the nearest-rank method; every value it gives is a real sample.

With numbers

The 1,000 requests above. For p50, r = 500, so 5 ms. For p99, r = 990, so 50 ms. For p99.9, r = 999, and sample 999 is still 50 ms: the 50 ms group ends there. Only the maximum, rank 1,000, is 5,000 ms.

Read a percentile off the sorted samples

The line is all 1,000 samples sorted, on a log scale; the last 100 ranks are stretched so you can see the tail. The marker is the rank you read. The dashed line is the mean. Pick a sample and move the percentile.

p99

The first sample is the worked example above. The long-tailed sample is drawn from a lognormal plus rare pauses, made up for this page. Values use the nearest-rank method.

Tools disagree in the tail. NumPy's default interpolates between neighbours, so it reports p99.9 of the same sample as 54.95 ms. Name your method.

Failure. Symptom: a load test reports p99 = 20 ms, and production shows 400 ms. Measure: did the test tool wait for each answer before sending the next request? Cause: while one request was stuck, the tool sent nothing, so the slow period produced few samples. This is called coordinated omission. Fix: send at a fixed rate and time each request from when it should have been sent.

By nearest rank, what is p99.9 of the 1,000 requests (950 at 5 ms, 49 at 50 ms, 1 at 5,000 ms)?

Chapter 3

Fan-Out Turns Rare Slow Calls Into Common Slow Pages

Multiply the chances that every call is fast, and watch the page's tail grow

One page often calls many backend services in parallel: the cart, the prices, the stock, the recommendations. The page is ready only when the slowest call returns. So each extra call is one more chance to wait.

Call the chance that one call is slow p, for example 1% if "slow" means slower than that service's p99. Call the number of parallel calls n. The chance that the page waits for at least one slow call is Pslow.

Say it aloud

P-slow equals one minus, one minus p, to the n.

Pslow
P-slow the share of pages that wait for at least one slow call.
1 − p
one minus p the chance that one call is fast; p is the chance it is slow, 0.01 here.
n
to the n multiply by itself once per parallel call: the chance that all n calls are fast, if calls are independent.
In plain words

The chance one call is fast is 1 minus p. The chance all n are fast is that, n times over. One minus that is P-slow. For small n, P-slow is close to n times p.

With numbers

With p = 1%: n = 5 gives 4.9%, n = 20 gives 18.2%, and n = 100 gives 63.4%. The services each meet their own p99, yet at 100 calls most pages are slow.

Jeffrey Dean and Luiz André Barroso made this point in "The Tail at Scale" (Communications of the ACM, 2013). With 1 slow server in 100, requests that touch 100 servers are slow 63% of the time. Their fix is the hedged request. If a call has not answered by its usual p95 time, send a copy to another replica and take the first answer. A page is then slow only if both copies are slow, so p becomes about p squared.

Count the pages that wait

Each cell is one page; red cells waited for a slow call. The curve is the formula, and the dot is your setting. Drag the fan-out, then turn on hedging.

20

Illustrative: each call is slow with p = 1%, calls are independent, and a hedge is slow only if the backup is slow too. Real slow calls are often correlated, which makes hedging help less.

Hedging costs extra load: up to 5% more requests if you hedge at the p95 time. Dean and Barroso report one test where a 10 ms hedge cut the 99.9th percentile from 1,800 ms to 74 ms for 2% more requests.

Failure. Symptom: every service meets its p99 target, but the page misses its own. Measure: the number of calls per page, and the share of pages with at least one slow call. Cause: tail amplification across fan-out. Fix: fewer calls on the critical path, hedged requests, or a per-page time budget that drops optional parts.

A page makes 10 parallel calls, each slow 1% of the time. About what share of pages wait for a slow call?

Chapter 4

Targets, Error Budgets and Nines

Turn an uptime target into minutes of failure you may spend each month

A target needs three parts. A service level indicator (SLI) is what you measure: say, the share of requests answered within 200 ms. A service level objective (SLO) is its target: say, 99.9% over 30 days. A service level agreement (SLA) is a contract that says what the customer gets back if you miss. Keep the SLO stricter than the SLA, so you notice before the contract bites.

An availability target sounds like "almost always". It is a count of minutes that may go wrong. Call the target availability A and the length of the window T. The downtime you may spend is the error budget, B.

Say it aloud

B equals one minus A, times T.

B
B the error budget: minutes of downtime the target allows in the window.
A
A the availability target as a fraction: 0.999 for "three nines".
T
T the window in minutes. This page uses a 30-day month, 43,200 minutes, and a 365-day year, 525,600 minutes.
In plain words

Subtract the target A from 1 to get the share of time that may fail. Multiply by the window T. That is the budget B.

With numbers

A = 0.999 and T = 43,200 minutes: B = 0.001 × 43,200 = 43.2 minutes a month. Over a 365-day year it is 525.6 minutes, 8.76 hours.

TargetPer 30-day monthPer 365-day year
99% (two nines)432 min (7.2 h)87.6 h (3.65 days)
99.9% (three nines)43.2 min8.76 h
99.95%21.6 min4.38 h
99.99% (four nines)4.32 min52.6 min
99.999% (five nines)25.9 s5.26 min

Spend this month's error budget

Yellow marks are incidents on the month's timeline; the bar below is the budget. Choose a target, then add an incident or a risky deploy.

Illustrative month: incidents of 8 and 10 minutes on days 4 and 12, and today is day 20. Budgets use a 30-day month.

The budget makes risk a shared decision. At 99.95%, the month allows 21.6 minutes. After 18 minutes of incidents, 3.6 remain, so a deploy that might cost 5 minutes waits. Google's SRE book describes this way of setting targets in detail.

Failure. Symptom: the team meets its internal target and still owes customers credits. Measure: compare the SLO with the SLA and the window each uses. Cause: the SLO equals the SLA, or uses a different month length. Fix: set the SLO stricter than the SLA and state one window for both.

The target is 99.95% over a 30-day month. It is day 20, and incidents have used 18 minutes. How much budget is left?

Chapter 5

Hardware Faults: Count Them

Divide a fleet by each part's lifetime, and plan for a death every day

Two words first. A fault is one part going wrong: a dead disk, a crashed process. A failure is the whole system no longer giving the service users need. A fault-tolerant system stops faults from turning into failures. A part whose fault alone causes a failure is a single point of failure.

One disk rarely dies. A fleet of disks dies all the time. Call the number of disks N, and the mean time one disk runs before it fails MTTF, in hours. The expected failures per hour across the fleet are F.

Say it aloud

F equals N divided by M-T-T-F.

F
F the expected disk failures per hour in the whole fleet. Multiply by 24 for a day.
N
N the number of disks running, here 10,000.
MTTF
M-T-T-F, mean time to failure the average hours one disk runs before it fails. It assumes failures arrive at a steady rate.
In plain words

Each disk fails about once per MTTF hours. N disks fail N times as often. Divide N by MTTF to get F, the failures per hour.

With numbers

A datasheet MTTF of 1,000,000 hours and N = 10,000: F = 0.01 an hour, 0.24 a day, about 88 a year. At a 3% yearly failure rate, MTTF is about 292,000 hours, and the fleet loses 0.82 disks a day, 300 a year.

Run a fleet for one year

Each cell is a group of purple disks; it flashes red when one of its disks dies, then turns purple again once the disk is replaced. Choose the fleet size and the failure rate, then run a year.

10,000

Failures are drawn at random at the chosen rate (a Poisson process). The 3% rate sits inside the 2 to 4% field range that Schroeder and Gibson measured.

Datasheets are optimistic. Bianca Schroeder and Garth Gibson studied about 100,000 drives at large sites (FAST 2007). The datasheets implied at most 0.88% a year. In the field, yearly replacement rates of 2 to 4% were common, and some sites reached 13%. So plan with field rates. Keep each piece of data on several disks, and replace dead ones fast.

Failure. Symptom: data is lost after "only" two disk deaths. Measure: the time from a disk's death to its data being copied again. Cause: the second copy died before anyone replaced the first. Fix: three copies on different machines and racks, and automatic re-copying within hours.

A fleet has 20,000 disks with an MTTF of 1,000,000 hours. About how many die each day?

Chapter 6

Redundancy, and Faults That Hit Every Copy

Multiply the chances that all copies are down, then see a shared bug break the sum

Run two copies of a service behind a load balancer, and it is down only when both are down. Call one copy's availability A, and the number of copies r. The availability of the group is Ar.

Say it aloud

A-r equals one minus, one minus A, to the r.

Ar
A-r the share of time at least one of the r copies is up.
1 − A
one minus A the share of time one copy is down; A is one copy's availability, 0.999 here.
r
to the r the chance that all r copies are down at once, if they fail independently.
In plain words

Take the share of time one copy is down, 1 minus A. Raise it to the power r for all copies down together. Subtract from 1 to get A-r.

With numbers

A = 0.999. One copy is down 43.2 minutes a month. Two copies: A-r = 1 − 0.001² = 0.999999, about 2.6 seconds a month. Three copies: 0.999999999.

The word "independently" carries the whole result. Hardware faults are mostly independent. Software faults are not: one bad release, one input that crashes the parser, or one expired certificate takes down every copy at once. Call the share of time such a shared fault is active q. Then all copies fall together.

with a shared fault: A ≈ (1 − q) · Ar q = 0.0005, two copies: 0.9995 × 0.999999 = 0.9995 → 21.6 min a month down

Add copies, then add a shared bug

Warm boxes are copies; the bar is downtime a month on a log scale against the 43.2-minute budget of 99.9%. Add copies, then turn on the shared bug.

99.9%

Illustrative: copies fail independently except for the shared bug. Downtime uses a 30-day month.

People cause shared faults too. David Oppenheimer, Archana Ganapathi and David Patterson studied failures at three large Internet services (USITS 2003). Operator error was the largest single cause in two of the three, and configuration errors were its largest kind. The fixes are design, not blame: roll out changes to a few machines first, make rollback one step, and test with injected faults. Failure Modes, Resiliency Patterns and Testing and Deployment show how.

Failure. Symptom: three replicas, and all three crash within a minute. Measure: did they run the same release and receive the same input? Cause: a correlated software fault. Fix: staged rollouts with automatic halt, and limits on bad input.

Two copies, each 99.9% available, run the same release. A bad release takes both down 0.05% of the time. What availability do you get?

Chapter 7

Scalability: Describe the Load, Then Size the Workers

Use Little's law to count requests in flight, and a queue model to choose the workers

Scalability is a question, not a label: if the load grows this way, what happens? Describe the load with load parameters: requests a second, read-to-write ratio, fan-out, data size. Then ask what keeps performance when they grow.

A useful first law links three numbers. Call the arrival rate λ (lambda), in requests a second, and the mean time each request spends in the system W. The mean number of requests in flight is L.

Say it aloud

L equals lambda times W.

L
L the average number of requests inside the system at once.
λ
lambda the arrival rate, in requests a second. In a steady state it equals the throughput.
W
W the average time one request spends inside, waiting plus being served, in seconds.
In plain words

Multiply how many requests arrive each second, lambda, by how long each stays, W. That is how many are inside at once, L. This is Little's law, and it needs no assumptions about the arrival pattern.

With numbers

With made-up numbers: lambda = 2,000 a second and W = 50 ms, so L = 100 requests in flight. If a slow database makes W 500 ms, L becomes 1,000. A thread pool of 200 is full, and new requests are refused.

Now size the workers. Call one request's service time s, and the busiest share of time you allow each worker ρmax (rho-max). The workers needed are c.

Say it aloud

c equals the ceiling of lambda times s, over rho-max.

c
c the number of workers: threads, processes or machines that each serve one request at a time.
λ
lambda the peak arrival rate, 3,000 requests a second here.
s
s the service time of one request, 20 ms here. Lambda times s is the work, in "workers busy on average".
ρmax
rho-max the highest utilization you plan for, 0.7 here; the rest is headroom for surges and lost machines.
In plain words

Multiply the rate lambda by the service time s to get the workers that would be busy all the time. Divide by rho-max for headroom, and round up. That is c.

With numbers

lambda = 3,000 a second and s = 0.02 s: 60 workers' worth of work. Divided by 0.7 that is 85.7, so c = 86.

Size a pool of workers

Warm cells are busy workers, pink cells are idle. The curve is the p99 queue wait for each worker count; the dashed line is the 70% rule. Drag both sliders.

3,000/s
64

Model: random arrivals, random service times with a 20 ms mean, one shared queue (the M/M/c queue, solved with the Erlang C formula). Illustrative numbers.

At 64 workers the pool is 94% busy, yet the p99 wait is 19.6 ms. One server at 94% busy would make the mean response 16 times its service time. A shared pool absorbs bursts far better.

Past one machine, you buy a bigger one (scaling up) or add machines that share nothing and split the work (scaling out). Load Balancing and Sharding cover scaling out.

Failure. Symptom: one slow dependency, and the whole service stops answering. Measure: requests in flight against the pool size. Cause: by Little's law, W went up 10 times, so L did too, and the pool filled. Fix: timeouts on every call, and a separate pool per dependency.

A service gets 1,500 requests a second, and each spends 80 ms inside. How many requests are in flight on average?

Chapter 8

Maintainability: Repair Time Is Part of Uptime

Shorten the time to repair, and watch availability climb without one extra machine

Most of a system's cost comes after launch: running it, fixing it and changing it. Maintainability has three parts. Operability means the people on call can see what the system does and act fast. Simplicity means newcomers can understand it, because good abstractions hide the accidental complexity. Evolvability means it can change as needs change.

Operability shows up in a number. Call the mean time between faults MTTF, and the mean time to notice and repair one MTTR. The share of time the service is up is A.

Say it aloud

A equals M-T-T-F divided by M-T-T-F plus M-T-T-R.

A
A availability: the share of time the service is up.
MTTF
M-T-T-F, mean time to failure the average up time between faults, 720 hours (30 days) here.
MTTR
M-T-T-R, mean time to repair the average time from the fault to service restored: noticing, finding the cause and fixing it.
In plain words

Each cycle is MTTF hours up, then MTTR hours down. Divide the up part by the whole cycle to get A.

With numbers

MTTF = 720 h and MTTR = 4 h: A = 720 / 724 = 99.45%, about 239 minutes down a month. Cut MTTR to 15 minutes: A = 99.965%, 15 minutes a month. The same faults, 16 times less downtime.

Shorten the repair, keep the faults

Each row is a month. Each red bar is one outage, as wide as its repair. The faults stay the same; drag the repair time.

4 h

Illustrative: faults arrive at random with an MTTF of 720 hours, the same seed at every repair time. Bars narrower than a pixel are drawn at 2 px so you can see them.

What cuts MTTR? Seeing the problem: dashboards and alerts on what users feel, latency, traffic, errors and saturation (Observability). Undoing a change in one step. Runbooks that say what to do. Simplicity cuts it too: a system people understand gets fixed faster.

Failure. Symptom: a bad deploy takes four hours to fix, though rolling back takes two minutes. Measure: split MTTR into time to notice, time to diagnose and time to fix. Cause: no alert on user-facing errors, and nobody could tell which change broke it. Fix: alert on symptoms, link each alert to a runbook, and record every deploy where the dashboard shows it.

A service fails about once every 720 hours. What does cutting the mean repair time from 4 hours to 1 hour do to monthly downtime?

Chapter 9

Write the Requirement Sheet, Then Meet It

Set six dials for one service and watch each target turn green or red

Here is a requirement sheet for a page served at 3,000 requests a second. 99% of pages finish within 100 ms. The service is up 99.9% of a 30-day month, so 43.2 minutes of budget. The p99 queue wait at peak stays under 10 ms. Each row below uses one equation from this lesson.

The dials map to chapters: the calls per page and hedging to Chapter 3, copies and the shared bug to Chapter 6, workers to Chapter 7, and repair time to Chapter 8. Start from the defaults: three rows are red. Fix them for the fewest machines.

Meet the three targets

Each bar is one requirement. Green meets the target, red misses it. The last row counts machines. Change one dial at a time.

20
64

Copies of each tier

Mean time to repair

Illustrative model from Chapters 3 to 8. Calls are slow 1% of the time; a hedge makes that 0.01% for 5% more calls. Three tiers in series, each copy with an MTTF of 720 h. A shared bad release hits a tier once in 90 days and lasts one repair time. Each machine runs 16 workers.

Two lessons fall out. Copies fix independent faults but not shared ones; with shared bad releases on, only a shorter repair brings downtime under budget. And the latency row ignores machines entirely: no hardware fixes a page that makes 60 calls.

Failure. Symptom: the team adds machines and the p99 does not move. Measure: which row is red, and which dial moves it. Cause: the tail comes from fan-out, not from load. Fix: change the dial that moves the red row: fewer calls or hedging.

Shared bad releases are on, each tier has 2 copies, and repair takes 1 hour. Downtime is about 60 minutes a month against a 43.2-minute budget. What fixes it?

Chapter 10

The Field Guide

Keep the numbers, the checklist and the code for your next requirement sheet

Write every quality as a number with a window. Describe load by its rate and its spread, including the fan-out. Describe response time by percentiles, and expect fan-out to amplify the tail. Turn uptime into minutes of budget. Count hardware faults by fleet size, and remember that shared software and human faults defeat copies. Size workers from the load, and cut repair time as hard as you cut faults.

Terms and numbers

TermWhat it isThis lesson's number
Fan-out workC = R · kpull 60 M lookups/s, push 1.2 M inserts/s
Percentile rankr = ⌈p/100 · N⌉p99 of 1,000: rank 990, 50 ms; p99.9: rank 999, 50 ms
Tail amplificationPslow = 1 − (1 − p)np 1%: 18.2% at n 20, 63.4% at n 100
Error budgetB = (1 − A) · T99.9%: 43.2 min per 30-day month
Fleet failuresF = N / MTTF10,000 disks: 0.24 a day (datasheet), 0.82 (3% a year)
RedundancyAr = 1 − (1 − A)r0.999, two copies: 0.999999; shared fault 0.05%: 21.6 min/month
Little's lawL = λ · W2,000/s × 50 ms = 100 in flight
Workersc = ⌈λ · s / ρmax⌉3,000/s × 20 ms / 0.7 = 86
Repair and uptimeA = MTTF / (MTTF + MTTR)720 h, 4 h: 99.45%; 15 min: 99.965%

Checklist

  1. Write the load parameters: peak rate, read-to-write ratio, fan-out and its largest case.
  2. Write latency targets as percentiles with a window, and name the percentile method.
  3. Count the calls on each page's critical path, and compute the page's slow share.
  4. Turn the uptime target into minutes of budget, and keep the SLO stricter than the SLA.
  5. Plan hardware with field failure rates, not datasheets.
  6. For each set of copies, name what they share: release, config, dependency.
  7. Size workers with Little's law and a queue model, and set timeouts on every call.
  8. Measure MTTR in parts, notice, diagnose and fix, and shorten the largest.

The core as code

pythonimport math
# the lesson's requirements as functions you can call with your own numbers
def fanout(R, k):              return R * k                          # C = R·k
def pct(xs, p):                return sorted(xs)[math.ceil(p / 100 * len(xs)) - 1]  # nearest rank
def slow_share(p, n):          return 1 - (1 - p) ** n
def budget_min(A, T=43200):    return (1 - A) * T                    # 30-day month
def fails_per_day(N, mttf_h):  return N * 24 / mttf_h
def copies(A, r, q=0):        return (1 - q) * (1 - (1 - A) ** r)
def in_flight(lam, W):         return lam * W                        # Little's law
def workers(lam, s, rho=0.7):  return math.ceil(lam * s / rho)
def uptime(mttf, mttr):        return mttf / (mttf + mttr)

xs = [5] * 950 + [50] * 49 + [5000]
print(sum(xs) / 1000, pct(xs, 99), pct(xs, 99.9))   # 12.2 50 50
print(slow_share(0.01, 20))                   # 0.182
print(budget_min(0.999))                       # 43.2 minutes
print(fails_per_day(10_000, 1_000_000))       # 0.24
print(copies(0.999, 2, q=0.0005))              # 0.9995
print(in_flight(2000, 0.05), workers(3000, 0.02))  # 100.0 86
print(uptime(720, 4))                          # 0.99448

Keep going

The takeaway. A requirement is a number with a window and a percentile. Once each quality has one, every design choice becomes arithmetic you can check.

Now press Present or Teach and explain four things from memory: why the mean hides the tail, why fan-out amplifies it, why copies do not stop a shared bug, and why repair time matters. Then go back to the hero and find the fan-out where half the pages are slow.

Nonfunctional Requirements · following Designing Data-Intensive Applications, 2nd edition, Chapter 2
Previous: Trade-Offs · Next: Data Models · Back to Gleams