Sub topic 2
Pin down functional and non-functional requirements
This chapter assumes you know the basics of client-server architecture, HTTP APIs, and databases. The previous chapter covered framing an open-ended problem. Here you turn that framing into a short, checkable list of requirements.
Why requirements come first
A prompt like "design a URL shortener" fits many different systems. A shortener for an internal team and one for a global ad network need different storage, caching, and failure handling. Requirements are the facts that choose between those designs. Without them, every later decision is a guess.
There are two kinds:
- Functional requirements say what the system does: the actions users or other systems can take.
- Non-functional requirements say how well it does them: speed, availability, durability, consistency, and cost.
Functional requirements
Write them as short verbs on a noun. For a URL shortener:
- A user can create a short link for a long URL.
- Anyone can open a short link and be redirected.
- A user can see click counts for their own links.
Keep the list small, usually three to five items. Each one should map to something you can later turn into an API call. If you can't picture the request, the requirement is still vague.
Ask questions that split the problem:
- Who are the users, and are there different roles?
- Which actions are most common?
- Can data be edited or deleted, or only added?
- Is there any feature you should explicitly leave out?
Non-functional requirements
These are the ones that shape the architecture. Turn each vague word into a number or a named choice.
| Vague wish | Testable requirement |
|---|---|
| "Fast" | Redirects complete in under 100 ms at the 99th percentile |
| "Reliable" | 99.95% monthly availability for redirects |
| "Doesn't lose data" | Created links are never lost once acknowledged |
| "Scalable" | Handles 10x traffic growth within a year |
| "Consistent" | A new link works everywhere within 5 seconds |
Notice that one system can have different targets for different operations. Redirects may need high availability and low latency. Click-count reports may tolerate delay. Splitting requirements by operation avoids over-building the whole system.
Requirements pull against each other
Strong consistency, high availability, and low latency are hard to maximize together, especially across regions. Requirements are the place to say which one wins when they conflict. Record that choice now, because later trade-off discussions refer back to it.
Common errors
- Listing features without numbers. "Low latency" cannot be checked. Add a percentile and a threshold.
- Asking questions forever. Ask the few that change the design, then state assumptions and move on. The next chapter covers this.
- Quietly adding features. Every extra feature adds components. Keep a short "out of scope" list.
- Treating all operations alike. Reads and writes often have very different needs.
- Skipping confirmation. Read the list back to the requester. A one-minute check can prevent a redesign.
A worked mini-list
For the shortener, a confirmed list might read:
- Functional: create link, redirect, per-link click counts.
- Out of scope: custom domains, link editing.
- Non-functional: redirect p99 under 100 ms, 99.95% availability, no loss of acknowledged links, click counts may lag by a minute.
This list is short enough to keep visible while you work. Every later step, from capacity estimates to storage choice, should trace back to a line in it.
Exercise
A team wants a chat app that is "real-time and reliable." Rewrite those two phrases as testable non-functional requirements, and state one functional requirement and one out-of-scope item.
Show answer
Example answer: "Messages are delivered to online recipients within 500 ms at the 99th percentile" and "A message acknowledged to the sender is never lost, even if one server fails." Functional: a user can send a text message to another user. Out of scope: video calls or end-to-end encryption. Any similar numeric targets are acceptable, as long as each one can be measured.