SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
  • What is System Design?
  • High-Level Design (HLD)
  • Low-Level Design (LLD)
  • Functional vs Non-Functional Requirements
  • Back-of-the-Envelope Estimation
  • Numbers Every Engineer Should Know
  • SLA, SLO and SLI
  • Basic OS: Process, Thread, Memory
  • 30 Must-Know Concepts
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Foundations/Introduction

Functional vs Non-Functional Requirements

What the system must do, and how well it must do it. The first thing to ask in any design.

โฑ 12 min readBeginnerMust KnowHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

Functional requirements say what the system must do. Non-functional requirements say how well it must do it.

  • Functional: "A user can upload a photo." It is a feature, an action with a result.
  • Non-functional: "The page loads in under 200 ms and the service is up 99.99% of the time." It is a quality, written as a number.
  • Features decide what you build. Quality targets decide how you build it, and most of the cost.
  • The very first step of any system design is to ask about both.

02Concept: What is it?

A requirement is something the system has to do or has to be. We split requirements into two families, because they are used in different ways.

Functional requirements describe behaviour: the features and the rules of the business. If you took one away, a user would say, "I cannot do that any more."

Non-functional requirements (also called quality attributes) describe the qualities of the system: speed, safety, size, and how often it is available. If you took one away, a user would say, "It still works, but it is too slow, too fragile or not safe."

Two kinds of requirements
Functional: WHAT
๐Ÿ“คUpload a photo
๐Ÿ”Search posts
๐Ÿ””Send a notification
Non-functional: HOW WELL
โšกFastp95 under 200 ms
๐ŸŸขAlways on99.99% available
๐Ÿ“ˆBig50,000 req/s at peak
Features Quality targets
The same product has both. A good design starts by writing both down.
๐Ÿง A quick test
A functional requirement is usually a verb (upload, search, pay). A non-functional requirement is usually an adjective with a number (fast, safe, always on, 10 million users).

03Real-Life Example

๐ŸตOrdering a Taxi
You order a taxi. The functional need is simple: take me from home to the airport. But you also care about how: arrive in 5 minutes, be safe, be clean, cost a fair price, and be there even when it rains. Two taxi companies can both "take you to the airport". You pick the one with the better qualities. In software it is the same: many apps have the same features, and users stay with the one that is fast and reliable.
Taxi ride
Software system
Take me to the airport
A functional requirement (the feature)
Arrive within 5 minutes
A latency target (non-functional)
A driver is available even at 3 am
An availability target
Works on a busy Friday night
A scalability target
The driver is safe and the payment is protected
Security (non-functional)
The meter shows the right price
Correctness (a functional rule)
A cheaper, slower ride costs less
A trade-off between cost and quality
Requirements come before design
โ“Askwhat and how well?
โ†’โ†“
๐Ÿ“Write downfeatures + targets
โ†’โ†“
๐ŸงฉDesignpick parts to meet them
โ†’โ†“
โœ…Checkdid we meet the numbers?

04Why Do We Need It?

๐ŸŽฏKnow what to build
Without clear features you build the wrong thing, or too much.
๐Ÿ“Make quality testable
"Fast" is an opinion. "Under 200 ms for 95% of requests" is a goal you can measure.
๐Ÿ—๏ธChoose the right design
A chat app for 100 people and one for 100 million need very different designs.
๐Ÿ’ฐControl cost
Every extra nine of availability or every millisecond saved costs money. Write down what is really needed.
๐ŸคAgree with the business
Numbers turn a vague wish into a promise everyone understands (see SLA, SLO and SLI).
๐ŸŽคDo well in interviews
A strong answer always starts by asking about features and scale before drawing boxes.
Features tell you what to build. Quality targets tell you how big, how fast and how safe it must be, and that drives the design.

05Where Do We Use It?

๐ŸŽคDesign interviews
The first five minutes: clarify the features, then the scale, speed and availability.
๐Ÿ“‹Product planning
User stories and specifications list the features. Engineers add the quality targets.
๐Ÿ“œContracts
A service-level agreement turns quality targets into a promise to a customer.
๐ŸงชTesting
Functional tests check features. Load, security and failure tests check the qualities.
๐Ÿ“Architecture decisions
Teams write down which qualities matter most, then pick patterns to match.
๐Ÿ”ŽCode and design reviews
A review asks, "What happens at 10 times the traffic? What if this part fails?"

06Types / Parts / How It Works

Common non-functional requirements

QualityThe question it answersExample target
Performance (latency)How fast is one request?p95 under 200 ms
ScalabilityHow much load can it take, and grow to?50,000 requests per second at peak
AvailabilityHow much of the time is it up?99.99% per month
ReliabilityDoes it give the right answer, every time?No wrong charges
DurabilityIs stored data ever lost?No acknowledged write is lost
ConsistencyDo all users see the same data?A new post is visible within 5 seconds
SecurityWho can see or change what?All data encrypted; every action is logged
MaintainabilityHow easy is it to change and fix?A fix can be released in under a day
CostHow much may it cost to run?Under a set amount per month

Turning a vague wish into a requirement

Vague wishBetter requirement
It should be fast95% of searches return in under 300 ms
It should never go down99.95% availability each month, with failover in under 60 seconds
It must scaleHandle 10 million daily users and 20,000 requests per second at peak
It must be securePasswords stored with a slow salted hash; all traffic over TLS
๐Ÿ“Note
Some quality requirements overlap with each other and pull in opposite directions (for example, strong consistency and low latency across the world). Part of the work is choosing which one wins.
VisualizerSort the requirements, then see how a quality target changes the designFirst decide if each requirement is functional or non-functional. Then pick one quality (speed, availability, scale or durability) and make it stricter. The features stay the same but the design grows.
Part 1: Sort the requirements
A user can upload a photo
The home page loads in under 200 ms for 95% of requests
Users can follow and unfollow each other
The service is up 99.99% of the time
A user can search posts by keyword
The system must handle 50,000 requests per second at peak
Passwords are stored with a slow, salted hash
The system sends an email when an order ships
No order is lost, even if a data centre burns down
A manager can export a monthly report as CSV
Answered
0 / 10
Correct
0
Read each requirement and decide: does it say WHAT the system does (functional), or HOW WELL it does it (non-functional)?
Part 2: One quality target changes the design
Pick a non-functional target
Target: 99.9% (about 8.8 hours a year)
The design probably needs:
  • Two or more servers behind a load balancer
  • Health checks
  • A database replica
Relative cost and effort (illustrative, 1 to 10)3 / 10

The features stay the same at every level: the user can still upload, follow and search. Only the quality target changes, and so does the bill. The cost scores are made-up teaching numbers.

07How to Use It / Steps / Implementation

Gathering requirements in a design discussion

  1. 1
    Ask about the core features
    Start with the 2 or 3 main actions. For a photo app: upload, view, follow. Write them down and agree they are in scope.
  2. 2
    Say what is out of scope
    It is fine to say, 'I will skip payments and ads for now.' Smaller scope means a clearer design.
  3. 3
    Ask about scale
    How many users? How many are active each day? How many requests, and how much data? Rough numbers are enough.
  4. 4
    Ask about speed
    Is a response needed in 100 ms, or is a few seconds fine? Is it read-heavy or write-heavy?
  5. 5
    Ask about availability and durability
    Is a short outage acceptable? Can any data be lost? A bank and a meme app give different answers.
  6. 6
    Ask about security and rules
    Is the data private? Are there legal rules about where data is kept or how long?
  7. 7
    Write the numbers down
    Put the features and the targets in a short list you can come back to and check at the end.
๐Ÿ’กRank the qualities
You cannot have everything. Ask, "If I must choose, what matters most: speed, availability, consistency or cost?" The answer shapes the whole design.

08Key Terms to Know

TermMeaning in easy words
RequirementSomething the system must do or must be
Functional requirementA feature or behaviour: what the system does
Non-functional requirement (NFR)A quality of the system: how well it works
Quality attributeAnother name for a non-functional requirement, such as speed or safety
ScopeThe list of things that are in the project, and those that are not
LatencyHow long one request takes
ThroughputHow many requests per second the system handles
AvailabilityThe share of time the system is up and usable
DurabilityStored data is not lost, even after failures
SLA / SLO / SLIA promise, a target and a measurement of quality (see the SLA, SLO and SLI topic)
Trade-offGetting more of one quality by accepting less of another

09Pros, Cons and Trade-offs

โœ… Pros
  • Everyone agrees on what is being built
  • Quality becomes a number you can test
  • Prevents over-building and under-building
  • Makes design choices easy to explain and defend
  • Gives you a checklist at the end of the design
โš ๏ธ Cons
  • Takes time before any building starts
  • Numbers are guesses early on and can be wrong
  • Requirements change as the product grows
  • Too many strict targets make the design expensive
  • Teams often forget to write the non-functional ones

Trade-offs

ChoiceWe gainWe lose
Strict latency targetA snappy productMore caches, more regions and more cost
Very high availabilityFewer outagesExtra servers, failover work and complexity
Strong consistencyEveryone sees the same dataHigher latency and lower availability in a network split
Strong security rulesSafer dataSlower development and more steps for users
Low costA cheaper billLess headroom for spikes and failures
Loose targetsFast and cheap to buildRisk of unhappy users when load grows

10Common Problems and Mistakes

Common mistakes

  1. Skipping requirements. Drawing boxes first, then discovering the design does not fit the need.
  2. Only listing features. Forgetting that speed, scale and safety decide the architecture.
  3. Vague words. "Fast" and "scalable" cannot be tested. Add numbers.
  4. Asking for everything. 100% available, instant and free does not exist. Rank the qualities.
  5. Gold-plating. Building for a billion users when you have a thousand.
  6. Never rechecking. Writing the targets once and not measuring them in production.

Things to watch

๐ŸงฉHidden requirements
Rules like privacy laws or audit logs are often not mentioned until late. Ask early.
๐Ÿ“ˆGrowth
Today's numbers will not hold. Ask what traffic looks like in a year or two.
โš–๏ธConflicting targets
Lowest latency and strongest consistency across the world can pull apart.
๐Ÿ”Changing needs
Requirements move. Keep the design easy to change.

11Real-World Examples

๐ŸฆA bank
Correctness and durability come first. A slightly slower page is fine, but a lost payment is not.
๐ŸŽฎAn online game
Low latency matters most. A tiny delay ruins the experience, and a lost frame is acceptable.
๐Ÿ“บVideo streaming
Very high throughput and smooth playback. Some quality loss is fine, but a stall is not.
๐Ÿ›’Online shop
Always on during sales, and no double charges. Consistency matters at checkout.
๐Ÿ’ฌA chat app
Messages should arrive fast and in order, and none should be lost.
๐ŸฅHealth records
Privacy and audit trails are strict rules that shape the whole system.
๐Ÿ“Note
The same feature, such as "send a message", can lead to very different designs because the quality targets differ.
Mini case: same feature, different targets
Casual chat for friends
๐Ÿ–ฅ๏ธA few servers
๐Ÿ—„๏ธOne database
Banking chat, 10 million users
๐Ÿ–ฅ๏ธMany servers
๐Ÿ–ฅ๏ธIn 3 zones
๐Ÿ—„๏ธReplicated, encrypted DB
๐Ÿ“œAudit log
Both products let a user send a message. The targets change the design.

12Related Topics to Read Next

What is System Design?โ†’

Gathering requirements is the first step of a design.

SLA, SLO and SLIโ†’

How quality targets become measurable promises.

Back-of-the-Envelope Estimationโ†’

Turn the scale requirement into real numbers.

Scalabilityโ†’

A key non-functional requirement.

Availabilityโ†’

Another key quality, measured in nines.

CAP Theoremโ†’

Shows why some quality targets conflict.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • โœ”Functional: what the system does (features, verbs).
  • โœ”Non-functional: how well it does it (speed, scale, safety, uptime).
  • โœ”Test: a feature is a verb. A quality is an adjective with a number.
  • โœ”Always ask: features, scope, scale, latency, availability, durability, consistency, security.
  • โœ”Make it testable: add numbers, such as "p95 under 200 ms".
  • โœ”Rank them: you cannot maximise every quality. Choose what matters most.
  • โœ”Impact: quality targets drive the architecture and the cost.
  • โœ”One line: "Features say what to build. Quality targets say how strong to build it."
โ† Previous
Low-Level Design (LLD)
Next โ†’
Back-of-the-Envelope Estimation