Skip to content

Requirements: what it does and how well

A requirement is something the system must do or be, stated so that you can tell whether it does. There are two kinds, and they behave very differently.

  • A functional requirement says what the system does: a behaviour someone can see and try. A customer can add a product to a basket. A seller can download their sales as a file.
  • A non-functional requirement says how well it must do it: a quality of the behaviour that a number can describe. Search answers in under 300 ms. Checkout is available 99.9% of the time. A confirmed order is never lost.

The names are unfortunate. Non-functional does not mean unimportant. It is usually the non-functional requirements that decide the architecture, because many designs meet the same features and only a few meet them at the required speed, size and reliability.

Mental model. A functional requirement is a verb: the system does something. A non-functional requirement is the number attached to the verb: how fast, how often, how many, how safely.

Eight requirements for an online shop. Decide for each: what it does, or how well?

Challenge

What it does, or how well?

A functional requirement says what the system does. A non-functional requirement says how well it must do it: how fast, how reliably, how large, how safe. Sort these requirements for the online shop.

Sorting needs JavaScript.

Categories

Functional: what it does
A behaviour someone can see and try: a feature.
Non-functional: how well it does it
A quality of the behaviour that a number can describe: speed, availability, durability, capacity.
  1. Line 1 of 8A customer can add a product to a basket and remove it again.
  2. Line 2 of 8Search results appear within 300 ms for 99% of requests.
  3. Line 3 of 8The shop accepts payment by credit card.
  4. Line 4 of 8The checkout is available 99.9% of the time.
  5. Line 5 of 8A customer can reset a forgotten password by email.
  6. Line 6 of 8An order that has been confirmed is never lost, even if a server fails.
  7. Line 7 of 8The shop handles 2,000 requests per second during the yearly sale.
  8. Line 8 of 8A seller can download their sales as a CSV file.

Check your answers at least once before looking at the answers.

Teams often write non-functional requirements as adjectives: the system must be fast, reliable, scalable, secure. An adjective cannot be tested, and it cannot lose an argument. Two people will read “fast” and mean different things, and nobody finds out until the system is live. Google’s guidance on service level objectives makes the same point: without an explicit target, users form their own beliefs about how the service performs, and those beliefs may have nothing to do with what the team intends.

A requirement you can test has four parts:

  1. What is measured: search latency, the share of requests that succeed.
  2. A number: 300 ms, 99.9%.
  3. A condition: at which load, for which kind of request, over which period.
  4. A share of requests or time: for 99% of requests, over a rolling 30 days.
Vague Measurable
Search should be fast 99% of search requests answer in under 300 ms, at up to 2,000 requests per second
Checkout must be reliable At least 99.9% of checkout requests succeed, measured over each calendar month
Orders must be safe No confirmed order is lost when any single server fails
It has to scale It handles 2,000 requests per second at the yearly sale, and a growth to 4,000 within two years

The “share of requests” part matters because averages hide the slow ones. A mean of 80 ms can hide one request in a hundred that takes four seconds. The next module is about percentiles.

A number such as 2,000 requests per second is not a guess. It comes from an estimate: how many users, how many requests each makes in a day, and how much busier the peak is than the average. Suppose the shop expects a million active users a day, each making about 40 requests, and its busiest moment is about four times the average.

Traffic calculator

Your numbers

million users

How many different people use the product on a typical day: daily active users, not registered accounts.

requests per user per day

Count the requests that reach the system, not the screens the user sees: opening one page can send ten requests.

×

How many times busier the busiest moment is than the average. It depends on the product and on time zones, so take it from your own traffic when you can. The starting 3 is only a round number for illustration.

Changing the numbers needs JavaScript. The result is for the starting numbers.

Result

Peak requests per second1.85K

On average: 463 requests per second.

How it is calculated

Each step shows its formula, the numbers that go in, and the figure that comes out.

  1. Requests per day

    D = U × q

    Every user makes the same number of requests, so the day's total is the number of users times the requests each one makes.

    U daily active users
    1M
    q requests per user per day
    40

    D requests per day40M

  2. Average requests per second

    A = D ÷ d

    Spread over the whole day. A day has 86 400 seconds; in back-of-envelope mode it is taken as 100 000.

    D requests per day
    40M
    d seconds in a day
    86.4K

    A average requests per second463

  3. Peak requests per second

    P = A × f

    A system is sized for its peak, not for its average.

    A average requests per second
    463
    f peak-to-average ratio
    4

    P peak requests per second1.85K

What a day's requests mean per second
Requests per dayAverage per second
1M11.6
10M116
40M · your traffic463
100M1.16K
1B11.6K
10B116K
Model notes

Assumptions

  • Every user makes the same number of requests. Real users do not: a few heavy users, bots and automatic retries add requests, so measure the spread if it matters.
  • The peak is the average times the ratio you enter. Real peaks depend on the product, the time of day and the time zones of the users, and a single event can exceed any ratio, so take it from your own traffic.

Simplifications

  • A day has 86 400 seconds. In back-of-envelope mode it is taken as 10^5 seconds, the nearest power of ten, so the averages come out about 14% lower than the exact ones.
  • In back-of-envelope mode, the counts and sizes you enter are rounded to the nearest power of ten before anything is calculated. The result is an order of magnitude, not a figure to buy against.

Parameter values are illustrative. They are not benchmarks of any real product.

The peak comes out near 1,850 requests per second, which the requirement rounds up to 2,000. A requirement is only as good as the estimate behind it, and the course has a whole module on estimating (Capacity Estimation).

Standards bodies list many quality characteristics. ISO/IEC 25010, for example, names performance efficiency, reliability, security and maintainability among others. Four of them come up in almost every design discussion:

  • Latency: how long a request takes. Stated as a percentile: 99% under 300 ms.
  • Availability: how often the system is there when asked. Stated as a share of requests that succeed, or of time that it is up. The next module is about what each “nine” costs.
  • Durability: whether data survives failure. Stated as what must never be lost, and under which failures.
  • Capacity: how much load it carries. Stated as a rate, a volume or a number of users, at its peak.

The SRE book gives an example of how precise availability can be made: a system that serves 2.5 million requests a day, with a daily availability target of 99.99%, can serve up to 250 errors and still meet its target for that day. That is a requirement you can check, with a calculator, at the end of each day.

What happens if you design first and ask later?

Section titled “What happens if you design first and ask later?”

A team builds the shop with a single database server because it is simple, and the features all work. Three weeks before launch, someone asks: “what if the server fails?” The requirement was never written. The answer turns out to be that orders placed since the last backup are lost, which the business would not accept.

Fixing it now means replication, failover and testing, a different architecture from the one the team built. The feature list never changed. Only the unwritten requirement did.

Asking for the non-functional requirements first is cheap. Discovering them late is expensive, because they change the structure, not the features. If you are ever asked to design a system, asking “how many users, how fast, how reliable, how much must it never lose?” is not stalling. It is the first step of the design.

  • A functional requirement says what the system does. A non-functional requirement says how well: how fast, how often available, how much it carries, how safely it keeps data.
  • Non-functional requirements usually decide the architecture, because many designs offer the same features.
  • An adjective is not a requirement. Write what is measured, the number, the condition, and the share of requests or time.
  • Averages hide slow requests. State latency as a percentile.
  • The numbers come from estimates, so a requirement is only as good as the estimate behind it.
  • Ask for the non-functional requirements first. Finding them late changes the structure, not just the features.

Next: constraints, the things you cannot negotiate, and why every design is a trade-off.

Your progress

Built by GhaziAlibi.

© ShardCraft. All rights reserved.