Sub topic 3
Non-functional requirements: how well it does it
A functional requirement says what a system does. A non-functional requirement (NFR) says how well it does it: how fast, how reliably, how securely, how cheaply it can be changed. This chapter assumes you know the functional side from the previous chapter, can read short Python snippets, and understand client-server systems, databases, and caching at a basic level.
What an NFR is
An NFR is a constraint on the quality of a behavior, not a behavior itself. "A user can delete a short URL" is functional. "A delete takes effect everywhere within 5 seconds" is non-functional. It describes the same feature, but it limits how well the feature must work.
NFRs are also called quality attributes. They matter because they, more than features, decide the shape of the architecture. Two systems with identical features can need entirely different designs if one must serve 100 requests a second and the other 100,000.
The main quality attributes
| Quality | Question it answers | Example target |
|---|---|---|
| Performance | How fast does it respond, and how much work can it do? | 99% of redirects under 100 ms |
| Availability | What fraction of the time does it work? | 99.9% of requests succeed over 30 days |
| Reliability | How often does it produce correct results without failing? | Fewer than 1 failed write per 100,000 |
| Scalability | Can it handle growth in load or data? | Supports 10x traffic by adding servers, with no redesign |
| Consistency | Do all readers see the same data? | A delete is visible to all readers within 5 seconds |
| Durability | Once acknowledged, is data kept? | An acknowledged write survives loss of one data center |
| Security and compliance | Who can do what, and which rules apply? | Personal data encrypted at rest; access logged |
| Maintainability and operability | How easily can it be changed, deployed, and diagnosed? | A new release deploys with no downtime |
Later chapters treat each of these in detail. Here the goal is to recognize them and write them properly.
Why vague NFRs fail
Many requirement documents contain statements like these:
- "The system must be fast."
- "The system must be highly available."
- "The system must scale."
None of these can be tested. Two engineers will read "fast" differently, and no measurement can ever show that the requirement was violated. A usable NFR has four parts:
- A quality (latency, availability, durability).
- A metric that measures it (the 99th percentile of redirect time).
- A target (under 100 ms).
- A measurement condition: where and over what period it is measured (at the service edge, over 30 days).
Compare the vague and measurable forms:
| Vague | Measurable |
|---|---|
| Redirects must be fast. | 99% of redirects complete in under 100 ms, measured at the service edge over 30 days. |
| The service must be reliable. | Redirects succeed for 99.9% of requests over a 30-day window. |
| We must not lose data. | A created short URL is never lost once creation has been acknowledged. |
The third row shows that a target need not be a percentage. "Never lost once acknowledged" is a precise, testable guarantee because it names the exact moment the promise starts, the acknowledgment.
The next chapters on measurable targets cover the vocabulary for these metrics (SLIs, SLOs, SLAs). For now, treat the four-part pattern as the checklist.
Recording NFRs next to functional requirements
Keep NFRs in their own numbered list, separate from features, and tag each with its quality. This makes them easy to review and to trace into design decisions later.
service: url-shortener
functional:
- id: FR-2
text: Requesting a short URL redirects to the original long URL.
non_functional:
- id: NFR-1
quality: latency
text: 99% of redirects complete in under 100 ms, measured at the service edge over 30 days.
- id: NFR-2
quality: availability
text: Redirects succeed for 99.9% of requests over a 30-day window.
- id: NFR-3
quality: durability
text: A created short URL is never lost once creation has been acknowledged.Notice that NFR-1 and NFR-2 both apply to FR-2. One feature usually carries several quality constraints, and each constraint may influence a different part of the design.
Making a number meaningful
A target is only useful if you know what it implies. Availability is a good example, because small changes in the percentage cause large changes in the allowed downtime. This function converts an availability target into a downtime budget:
def downtime_budget_minutes(availability, days=30):
"""Minutes of allowed downtime for an availability target over a window."""
return (1 - availability) * days * 24 * 60
print(round(downtime_budget_minutes(0.999), 1)) # 43.2
print(round(downtime_budget_minutes(0.9999), 1)) # 4.3Going from 99.9% to 99.99% looks like a tiny change. It cuts the monthly budget from about 43 minutes to about 4. A team that cannot respond to an incident in under 4 minutes needs automatic failover to meet the second target, and that has a cost. Always translate a percentage into time or counts before you accept it.
Percentiles work the same way for latency. An average hides slow requests, so latency targets use percentiles:
import math
def percentile(samples, p):
"""Nearest-rank percentile: the smallest value with at least p% of samples at or below it."""
ordered = sorted(samples)
rank = math.ceil(p / 100 * len(ordered))
return ordered[rank - 1]
latencies_ms = [12, 15, 14, 18, 20, 22, 25, 30, 40, 250]
print(percentile(latencies_ms, 50)) # 20
print(percentile(latencies_ms, 99)) # 250The median is 20 ms, which looks healthy. The 99th percentile is 250 ms, which exposes the slow outlier. A requirement stated only as "median under 50 ms" would pass while some users wait a quarter of a second.
Common errors
- Treating NFRs as an afterthought. Adding a 99.99% target after the design is done often means redoing it, because availability depends on structure such as replication and failover.
- Asking for the maximum everywhere. Every quality has a cost, and some conflict with each other. Strong consistency and very low latency across regions pull in opposite directions. Rank the qualities and choose targets per feature.
- Targets with no measurement point. "Under 100 ms" is ambiguous. It could be measured at the database, at the server, or at the user's browser, and these give different numbers.
- Mixing a feature into an NFR. "The system must support login" is functional. "Login must complete within 2 seconds for 99% of attempts" is the non-functional part. Split them.
- Inventing numbers with no source. A target should come from a user need, a business agreement, or a stated assumption. If you guess, record it as an assumption so it can be challenged.
Review checklist
For each NFR in a draft, check that it:
- Names one quality.
- Has a metric and a numeric target.
- States where and over what period it is measured.
- Can be traced to a feature, user need, or assumption.
- Does not contradict another NFR.
Exercise
Rewrite "The search page must load quickly and almost never go down" as two measurable non-functional requirements. Say which quality each one covers.
Show answer
Latency: "99% of search page loads complete in under 800 ms, measured at the service edge over 30 days." Availability: "Search page requests succeed for 99.9% of requests over a 30-day window," which allows about 43.2 minutes of downtime in 30 days. Each requirement names one quality, a metric, a numeric target, and a measurement window. Other values are acceptable if they are specific, testable, and justified by an assumption.
Exercise
A teammate proposes raising an availability target from 99.9% to 99.99% "because it is only 0.09% more". Using the downtime budget for a 30-day window, explain why this is a large change.
Show answer
At 99.9% the budget is about 43.2 minutes of downtime per 30 days. At 99.99% it is about 4.3 minutes, roughly ten times less. Meeting that usually requires automated failover and redundancy, because a human cannot reliably detect and fix an outage in under 4 minutes.