Sub topic 2
Pin down functional and non-functional requirements
This chapter assumes you know how client-server systems and HTTP APIs work, you have used a relational or key-value database, and you can read short Python snippets. The previous chapter argued that you should start with the problem, not the boxes. Here you turn a vague prompt into a list of requirements that you can design against and check later.
Why requirements come first
A prompt such as "design a service that stores short notes" does not tell you what to build. It does not say how many users there are, whether notes can be edited, or whether a lost note is a minor annoyance or a serious failure. Each of those answers changes the design.
Requirements are the contract between you and the person who posed the problem. They have two jobs:
- They limit the problem to something you can finish.
- They give you a standard to check the finished design against. The last chapter of this tutorial does exactly that check.
If you skip them, you will pick components by habit and then defend choices that nobody asked for.
Two kinds of requirements
Functional requirements describe what the system does. They are behaviors a user or another system can observe: "a user can create a note", "a user can list their own notes", "a user can delete a note".
Non-functional requirements describe how well the system does it. They are qualities and limits: how fast, how available, how consistent, how durable, how secure, and how much it may cost.
| Aspect | Functional | Non-functional |
|---|---|---|
| Answers the question | What does it do? | How well does it do it? |
| Example | Users can post an item | Posting takes under 300 ms at the 99th percentile |
| How you test it | Does the feature exist and work? | Does it meet a number under load? |
| Effect on design | Shapes the API and data model | Shapes the architecture, storage, and scaling |
Functional requirements tell you which components must exist. Non-functional requirements tell you how those components must be built, and they are usually what makes a design hard. A system that stores notes for ten users is a weekend project. The same feature set for ten million users with no data loss is a design problem.
Elicit functional requirements
Start with the actors. An actor is anyone or anything that uses the system: end users, administrators, other services, scheduled jobs. For each actor, list the actions they need.
A useful way to phrase each one is "an actor can do an action to an object". For the notes service:
- A user can create a note.
- A user can read a note by its identifier.
- A user can list their own notes, newest first.
- A user can delete a note.
Then ask questions that expose hidden features:
- Can a note be edited, or is it immutable after creation?
- Can notes be shared with other users? If so, are there permission levels?
- Is there search? Search over what fields?
- Are there attachments such as images or files?
- Does anything need to happen asynchronously, such as notifications?
Not every answer deserves a feature. Your job is to find the features that change the architecture. Search and sharing do. A "last edited" label usually does not.
Separate core from optional
Mark each requirement as must-have or nice-to-have. In a limited time, you design the must-haves fully and mention the others only briefly. A short, well-justified core beats a long list that you cannot finish.
Elicit non-functional requirements
Non-functional requirements are easy to forget because nobody states them as features. Walk through a checklist and ask whether each one matters here.
| Quality | Question to ask | Typical way to state it |
|---|---|---|
| Latency | How long can a request take? | p99 read under 200 ms |
| Throughput | How many requests per second? | 12,000 reads per second at peak |
| Availability | How much downtime is acceptable? | 99.9% monthly, about 43 minutes down |
| Consistency | Must readers see the latest write? | Read-your-own-writes for the author |
| Durability | Can we ever lose accepted data? | Acknowledged writes must survive a node failure |
| Scalability | How will load grow? | 3x growth over two years |
| Security | Who may see or change what? | Only the owner reads private items |
| Cost | Is there a budget? | Under a fixed monthly spend |
Two terms in that table are often confused. Availability is the share of time the system answers requests. Durability is the guarantee that data you accepted is not lost. A system can be down for an hour (poor availability) and still lose nothing (good durability).
Latency should be stated as a percentile, not an average. The p99 latency is the value that 99% of requests beat. An average hides the slow tail, and users notice the tail.
Turn adjectives into numbers
Words like "fast", "reliable", and "scalable" cannot be checked. Convert each into a number, or ask the interviewer or stakeholder for one. If nobody can give you a number, propose one and write it down as an assumption. The next chapter covers assumptions in detail.
A conversion of availability into allowed downtime shows why the digits matter. The script below does it.
MINUTES_PER_MONTH = 30 * 24 * 60
for target in (0.99, 0.999, 0.9999):
downtime = MINUTES_PER_MONTH * (1 - target)
print(f"{target:.2%} available -> {downtime:.1f} minutes of downtime per 30-day month")This prints roughly 432 minutes for 99%, 43.2 minutes for 99.9%, and 4.3 minutes for 99.99%. Each extra nine is about ten times harder to deliver. It usually needs redundancy across machines or data centers, automated failover, and careful deployments. So "four nines" is a costly requirement, not a harmless one.
Requirements that pull in opposite directions
Many non-functional requirements conflict. You cannot maximize all of them, so you need to know which ones to favor.
- Strong consistency often costs latency or availability. Making every reader see the newest write means coordinating between replicas.
- Low latency often costs durability or consistency. Acknowledging a write before it reaches disk is fast but risky.
- High availability costs money, because it needs spare capacity.
When a conflict appears, do not hide it. State which side wins for this problem and why. A payments ledger favors consistency and durability. A "likes" counter favors availability and low latency, and can tolerate a count that is briefly stale.
A worked example
Suppose the prompt is: "Design a service where users post short items and read them back."
You might ask a few questions and record the answers as requirements:
Functional (must-have)
- Create an item with an owner and a text body.
- Fetch one item by identifier.
- List a user's items, newest first, with pagination.
Functional (out of scope for now)
- Editing, sharing, search, attachments.
Non-functional
- Reads are far more common than writes, about 20 reads for each write.
- p99 read latency under 200 ms. p99 write latency under 500 ms.
- 99.9% availability.
- An acknowledged write must not be lost.
- A user must see their own new item immediately. Other users may see it a few seconds later.
- Items are private to their owner.
Notice what each line already suggests. A heavy read ratio points toward caching and read replicas. "Must not be lost" points toward replicated, durable storage. Allowing other users a few seconds of delay means you do not need strong consistency everywhere, which makes scaling cheaper.
The diagram shows how the pieces of this step connect.
Common mistakes
- Listing only features. A design that satisfies every functional requirement but ignores scale and failure is incomplete.
- Accepting vague words. "It should be fast" gives you nothing to design or test against.
- Asking questions that do not matter. Ten questions about the color of a button waste time. Ask the ones whose answers would change the architecture.
- Treating every requirement as equal. Rank them. When two conflict, the ranking decides.
- Not writing them down. Keep the list visible. You will refer back to it when you make trade-offs and again when you review.
- Asking for permission instead of proposing. If the person cannot answer, state a reasonable default and move on. Waiting for a perfect answer stalls the work.
A short checklist
Before you leave this step, check that you can answer yes to each item:
- Every actor and its main actions are listed.
- Each requirement is marked must-have or out of scope.
- Each important quality has a number or a clearly stated assumption.
- Conflicts between requirements are named, with a decision on which wins.
- No requirement names a specific technology.
Exercise
A team asks you to design a photo-sharing service. Write two functional and three non-functional requirements. Make each non-functional requirement measurable, and say which two of your requirements are most likely to conflict.
Show answer
One possible answer. Functional: (1) a user can upload a photo; (2) a user can view a photo by its link. Non-functional: (1) p99 photo load time under 300 ms; (2) 99.9% monthly availability; (3) an acknowledged upload is never lost. The most likely conflict is low latency against durability. Confirming an upload only after it is copied to several machines is safer but slower than confirming it after one write. A good answer states which side wins, here durability, since users expect uploaded photos to persist. Any measurable numbers are acceptable if they are stated as assumptions.
Exercise
A service promises 99.95% availability over a 30-day month. How many minutes of downtime does that allow, and what does the number tell you about whether a single server is enough?
Show answer
A 30-day month has 43,200 minutes. The allowed downtime is 43,200 x 0.0005 = 21.6 minutes. One server needs restarts, deployments, and hardware repairs, and a single failure can easily last longer than 21.6 minutes. So a single server is not enough. You need redundant servers behind a load balancer, with automatic failover and deployments that do not take the whole service down.