Study interactive :: Progress tools open in the Study Hub reader.

02. Design Requirements

Before you draw a single box on a system design diagram, you need to know what the system is supposed to do. This is where most interviews and most real projects go off the rails.

Two flavors of requirements

Functional: what the system does.

Non-functional: how the system behaves.

Functional requirements are usually obvious. Non-functional ones are where the architecture is born or dies.

The four non-negotiables

Every serious system asks these four questions:

Scalability Performance
Availability Consistency

Scalability

Can it grow? If 10x more users show up tomorrow, what breaks first?

There are two ways to scale:

Modern systems are horizontal by default because hardware stopped getting faster (see Chapter 0). The cost is complexity: load balancers, replication, distributed databases.

Performance

Two metrics, both important:

These are not the same thing. A system can be fast for one user and crawl under load. They trade off:

            high latency, low throughput  --> bad
            low latency, low throughput   --> okay for tiny systems
            high throughput, high latency --> okay for batch jobs
            low latency, high throughput  --> the goal

Latency is also a distribution, not a single number. People usually quote:

Why this matters: a system with 100 ms p50 and 5,000 ms p99 is unusable for the unlucky 1%. The average looks fine. The tail is on fire.

Availability

Is it up?

availability = uptime / total time

A year is 525,600 minutes. To hit 99.99%, you can be down at most ~52 minutes per year. That's not "we'll restart the server". That's "everything is redundant, automated, and tested".

Two tactics:

Consistency

When you write data, when does everyone else see it?

Pick wrong and you either lose money (bank with eventual consistency) or make a slow product (Twitter with strong consistency on a billion users).

We'll come back to this in the CAP chapter.

How to actually do back-of-the-envelope math

A real interview question:

"Design Twitter. How do you size it?"

Here's the recipe:

Step 1: estimate users.

Step 2: estimate writes.

Step 3: estimate reads.

Step 4: estimate storage.

Step 5: estimate bandwidth.

Now you know:

You didn't need a calculator. You just needed to multiply.

Useful numbers to keep in your head

Operation Time
L1 cache 1 ns
RAM 100 ns
SSD read 100 microseconds
Network round trip in same datacenter 0.5 ms
Network round trip cross-country (US east to US west) ~70 ms
Network round trip across continents (US to EU) ~100 ms
HDD seek 10 ms
Data Size
One tweet ~500 bytes
Average web page ~2 MB
Average photo (compressed) ~200 KB
Average song (MP3) ~5 MB
Movie (1080p, 2 hrs) ~5 GB
Scale Order
1 thousand (10^3) small product
1 million (10^6) growing product
1 billion (10^9) big tech

A worked example

"Design a URL shortener like bit.ly."

Requirements meeting:

Functional: paste a long URL, get a short one. Visit the short one, redirect to the long one. Track click counts.

Non-functional:

Quick math:

What you'd build:

Notice how the requirements drove the architecture. No CDN if all your users are in one city. No cache if every URL is equally popular. The numbers tell you what to build.

Things to remember

Going deeper