Two skills decide most of a system design interview. First, you turn a vague idea into clear requirements. Second, you turn those requirements into numbers. This lesson covers both. Quality targets from the requirements become the inputs of the estimate, and the estimate decides the architecture. The interview framework lesson gave the overview. Here is the detail.
1. Requirements Come First
"Design a chat app" is not enough to design anything. Each open question changes the architecture:
- One-to-one chats only, or large groups: a message to a group of 10,000 is 10,000 deliveries.
- Must messages arrive even if the phone is offline: you need to store them and push a notification.
- Must messages arrive in order and never twice: the delivery rules get stricter.
- How long is history kept, and can users delete it: the data model needs a lifecycle.
- Are messages end-to-end encrypted: the server cannot search or index their content.
A well-built system for the wrong problem is still a bad design. So understand the problem before you design the solution.
2. Three Kinds of Requirements
- Functional: what the system does. Example: create an order, search products, process a payment.
- Non-functional (NFR): how well it does it. Example: p99 latency under 200 ms, 99.99% availability.
- Constraint: a limit you did not choose. Example: a $20,000 monthly budget, a team of four, an existing PostgreSQL cluster, data that must stay in the EU.
NFRs and constraints often shape the architecture more than the feature list does.
2.1 Functional Requirements
Describe behavior, not just features. "Support payments" is too vague. Compare it with this: "A user can pay for an order. The system records the result and never charges the customer twice for the same order." Now the design needs are visible: a stored payment result, retries, and idempotency (doing the same request twice has the same effect as once).
A requirement you cannot test is not finished. Write it as given, when, then:
Given an order with a pending payment
When the client sends the same payment request twice with the same idempotency key
Then the customer is charged exactly once
And both requests return the same result
2.2 Non-Functional Requirements
The usual list: availability, latency, throughput, scalability, reliability (behavior when parts fail), durability (committed data is not lost), consistency (how fresh data must be), security, cost, and maintainability.
"Highly available", "fast" and "millions of users" are not requirements. A measurable NFR has five parts: the metric, the target, the measurement point, the time window and the conditions.
- Vague: "Highly available". Measurable: "99.99% of read requests return a non-5xx response, measured at the load balancer, per calendar month."
- Vague: "Fast". Measurable: "p99 latency under 200 ms for
GET /products/{id}, measured on the server, at up to 20,000 requests per second." - Vague: "Millions of users". Measurable: "2 million daily active users, peak 5,000 requests per second, 10x headroom for campaigns."
- Vague: "Reliable data". Measurable: "No acknowledged order is ever lost (RPO of zero). Recovery takes under 15 minutes (RTO)."
Three short terms are worth knowing. An SLI is a measurement, for example the share of requests that succeed. An SLO is your internal target for it, for example 99.9% a month. An SLA is the external contract with penalties, and you set it looser than the SLO. To turn an availability target into downtime, use the table in the Numbers lesson.
3. Scope: What Are We Building?
Requirements say what the system does. Scope says what is inside and outside it. Answer four questions:
- What do we own?
- What does another team or vendor own (for example, a payment provider)?
- What happens when an external dependency fails?
- Which features are left out on purpose?
Rank features with MoSCoW: Must have (the system does not work without it), Should have (important, but the first release can ship without it), Could have (nice if time allows) and Won't have this time. For a chat app: sending and receiving one-to-one messages is a must, group chats and offline delivery are shoulds, read receipts are a could, and voice calls are a won't. Say your scope out loud so the interviewer can correct it.
4. Clarifying Questions
Do not ask every possible question. Ask the ones whose answers change the design. The color of a button does not matter. "Can users upload 100 MB videos, or only small images?" changes everything: object storage, resumable uploads, transcoding, a CDN and bandwidth.
| Question | If the answer is A | If the answer is B |
|---|---|---|
| Read/write ratio and peak load? | Read-heavy (100 to 1): caching, replicas, denormalization | Write-heavy: partitioning, batching, queues |
| How stale can data be? | Seconds are fine: caches, asynchronous replication | Never: a single writer or strongly consistent store, higher latency |
| What availability, and for which features? | 99.9% for most: one region with failover | 99.99% for the core path: multiple zones or regions, automated recovery, degraded modes |
| Does the caller need the result now? | Yes: a synchronous call with a timeout | No: a queue and workers, with polling or events |
Other useful questions:
- Scale: how many users, how much data a day, how fast does it grow? "Millions of users" is not enough. 10 million registered users at 1,000 requests per second is a very different system from 1 million users at 100,000.
- Failure: what happens if this part is down for five minutes? Can the system run in a reduced mode?
- Easy to forget, costly to add later: who can see sensitive data, how long data is kept and deleted, and privacy rules such as GDPR.
When nobody can answer, do not stall and do not guess silently. State an assumption, say why, say what changes if it is wrong, and continue.
When requirements conflict (strong consistency against low latency, 99.99% against a small budget), name the conflict, put a cost on each option and let the owner decide. A conflict settled silently becomes a hidden trade-off that surprises people later.
5. Assumptions Are Not Facts
Early numbers are estimates. Write each one with its basis, its risk and a way to check it:
Assumption: 50,000 peak requests/second
Basis: 30M monthly users, 1% online at peak (300,000),
about 10 requests each per minute (300,000 x 10 / 60)
Risk: A marketing campaign could double it
Check: Load test at 2x and 10x, find the first bottleneck
Flip point: Above about 200,000 requests/second the cache tier
must be redesigned
The flip point is the value at which the architecture must change. Look for it on every risky assumption. Validate it with quick math and a load test before you commit.
6. Capacity Estimation: The Method
You want the order of magnitude, not an exact answer. A system with 100 requests per second is a different problem from one with 100,000. Each step below ends with a design decision.
flowchart LR
A["Assumptions"] --> B["Average rate, then peak"]
B --> C["Fan-out inside the system"]
C --> D["Concurrency and servers"]
D --> E["Cache memory"]
E --> F["Storage and growth"]
F --> G["Bandwidth"]
G --> H["Bottleneck and flip point"]
Reference machines (assumed): Java on Apache Tomcat on an AWS m5.xlarge (4 vCPU, 16 GB), Redis on an r5.xlarge (32 GB, about 24 GB usable), and a relational primary on an r5.4xlarge. Replace them with load-test results when you have them.
6.1 Rates: Average, Peak and Fan-Out
- Say which layer you count. One client request can cause many internal calls and database queries. Sizing the database from the client request rate, or the reverse, is a very common mistake. Keep three numbers separate: external requests, internal calls, and database operations.
- Average rate: divide the daily count by 86,400. Count reads and writes separately, because they are different workloads.
- Peak rate: size for peak, not average. Derive the multiplier from the shape of the day. If the busiest hour carries 10% of the day, it runs at 10% × 24 = 2.4 times the average. Bursts inside that hour add about 1.7 times. That gives about 4 times the average. A steady business API sees 1.5 to 2 times, a consumer app 3 to 5 times, and a ticket sale or breaking news 10 times or more.
- Call amplification: one request that makes 5 internal calls turns 4,640 requests per second into 23,200 calls per second.
- Write fan-out: a post that must be copied to 200 followers' timelines is 200 writes. The write rate you see in the product hides the write rate inside the system.
6.2 Concurrency and Little's Law
Threads, connections and memory are used by requests that are in flight: the arrival rate × the time each request spends in the system (Little's law, from the Numbers lesson). 4,640 requests/second at 0.05 s is about 230 in flight. If a dependency slows from 5 ms to 50 ms, in-flight work grows tenfold at the same request rate. This is how one slow dependency uses up all the threads and takes down a healthy service. It is why timeouts and bulkheads exist.
6.3 Servers and Headroom
Get per-server capacity from a load test: the rate one server sustains while meeting the p99 target at a safe CPU level (about 60 to 70%). Then divide the peak rate by it. Do not plan near 100%, because waiting time grows by about 1 ÷ (1 − utilization). Then add headroom for specific causes, not a vague "double it":
- Zone failure: if you run in three availability zones and must survive the loss of one, two zones must carry everything. You need 3 ÷ 2 = 1.5 times the healthy-state count, not 1.25 times.
- Autoscaling delay: new servers take minutes to help. If traffic can double faster than that, keep spare capacity warm or absorb the burst with queues and load shedding.
- Growth: capacity bought today must last until the next planned expansion.
6.4 Cache Memory
A cache helps only if the hot data fits in memory. Estimate the working set, not the whole dataset. Then add overhead (keys, structures, fragmentation), about 2 times for small items. To count nodes, take the larger of two answers: nodes needed for memory, and nodes needed for operations per second. Also state the hit rate your design relies on. A drop from 95% to 90% doubles database load.
6.5 Storage
Logical storage = records per day x size per record x retention days
Then add each overhead once:
- Indexes and metadata: usually 20% to 100% of the data size.
- Replication: 3 copies means 3 times the space for most databases. Erasure-coded object storage is about 1.5 times.
- Backups: at least one more full copy over the retention window.
- Free space: do not fill disks. Plan for 70% to 80% full.
Growth compounds, and retention multiplies. If daily volume grows 8% a month, the daily rate after 12 months is 1.0812 = 2.5 times today's. The 12-month total is (1.0812 − 1) ÷ 0.08 = 19 months of today's rate, not 12. Always ask how long data must be kept: 100 GB a day is 3 TB over 30 days but about 182 TB over five years.
6.6 Bandwidth
Bandwidth is requests per second times payload size. Count each direction separately, and multiply bytes by 8 to get bits. For media, a CDN takes most of the load, so the origin sees only the cache misses.
6.7 Bottlenecks and Flip Points
End-to-end capacity is set by the slowest part of the path. Estimate every important dependency, including outside providers. A call through a notification provider limited to 2,000 requests per second can never go faster, however many servers you add. Solve such limits with queues, batching or rate limits.
Then find the flip point. Say one primary should stay below 60% of 5,000 writes per second, which is 3,000. Today's peak is 2,500. With 8% monthly growth you pass 3,000 when 1.08n = 1.2, which is about 2.4 months away. In a year the peak is about 6,300. The conclusion: plan write partitioning now.
7. Worked Example: A Product-Analytics Event Pipeline
Assumptions: a SaaS product that collects usage events from its customers' apps. 5 billion events a day come from 2,000 customers. An event is about 500 bytes of JSON. The SDK sends events in batches of 50 per request, and each request takes about 50 ms. Peak is 4 times average. Raw events are kept for 90 days, and hourly rollups for dashboards are kept for 2 years. One app server handles 1,000 batch requests per second at a safe load (the bodies are about 25 KB), and a Kafka partition handles about 25,000 messages per second.
| Quantity | Calculation | Result and decision |
|---|---|---|
| Event rate | 5B ÷ 86,400 = 58,000/s. × 4 for peak | 230,000 events/s at peak |
| Request rate | 58,000 ÷ 50 per batch = 1,160/s. × 4 | 4,640 requests/s at peak. Batching cuts the request rate 50 times, so the API tier stays small |
| Requests in flight | 4,640 × 0.05 s | About 230. Small, so thread pools are not a worry |
| App servers | 4,640 ÷ 1,000 = 4.6. Zone loss: two zones carry the peak, 4.64 ÷ 2 = 2.3, round up to 3 per zone | 9 servers, 3 per zone |
| Kafka buffer | 230,000 ÷ 25,000 per partition = 9.2. Data rate: 230,000 × 500 B = 115 MB/s | Plan 24 partitions for headroom and consumer parallelism. A queue absorbs bursts so the store can load in batches |
| Raw storage | 5B × 500 B = 2.5 TB/day. × 90 days = 225 TB. Column compression of about 5x gives 45 TB. × 1.5 for erasure-coded copies | About 70 TB (340 TB without compression). Use columnar files in object storage. Keeping raw events for 5 years would be about 20 times more, so older data stays only as rollups |
| Rollup storage | 2,000 customers × 200 event types × 24 hours = 9.6M rows a day × 100 B | About 1 GB/day, 350 GB a year. Dashboards read rollups, not raw events |
| Bandwidth in | 4,640 × 25 KB = 116 MB/s. × 8 for bits | About 0.9 Gbps at peak. Responses are tiny. Compressing request bodies cuts it several times |
| Flip point | The largest customer sends 20% of events: 46,000/s against 25,000 per partition | Keying Kafka by customer alone overloads one partition. Key by customer plus a hash of the event ID |
What to say aloud: the API tier is small because the SDK batches events. The real problems are the raw storage (hundreds of terabytes, which forces columnar files, compression and a 90-day limit), the dashboards (which must read small rollups), and one large customer who can overload a single partition. The numbers are not exact, but each one led to a decision.
8. Common Pitfalls
- Designing before understanding. Boxes appear before anyone has asked about scale, consistency or scope.
- Vague requirements. "Fast" and "highly available" with no number, measurement point or window.
- Sizing for the average. State how you derived peak.
- Mixing layers, and missing fan-out. Client requests, internal calls and database operations are different numbers. The write rate inside the system can be 200 times what you see.
- No headroom reasoning. A flat "2 times" instead of zone loss, scaling delay and growth.
- False precision. 37.42 and "about 40" are the same when the inputs are rough. Give the order of magnitude and say what could make it wrong.
9. Interview Questions This Lesson Prepares You For
- What is the difference between functional and non-functional requirements? Functional ones say what the system does. Non-functional ones say how well: latency, availability, consistency, durability. NFRs usually shape the architecture more.
- How do you make a requirement measurable? Give the metric, target, measurement point, time window and conditions. "99.99% of reads return non-5xx at the load balancer, per month" is measurable. "Highly available" is not.
- Peak traffic is 4,640 requests per second and one server handles 1,000. How many servers? 5 in the healthy case. Across three zones, surviving one zone loss means two zones carry everything: 4.64 ÷ 2 = 2.3, so 3 per zone and 9 in total.
- A service runs at 100 ms and then its dependency slows down. Why does it fail even though traffic is the same? Requests in flight equal rate times latency, so slower calls hold threads longer, and the pool runs out. Use timeouts and bulkheads.
- The interviewer gives you no numbers. What do you do? State your assumptions with their basis, for example users × actions per day. Say what would change if they are wrong, and ask for a quick confirmation. Use round numbers, and take peak as about 4 times the average unless the shape of the day says otherwise.
- What is a flip point and how do you find it? It is the value at which the architecture must change. Estimate each limit on the path and divide it by the growth. A primary kept below 60% of 5,000 writes per second has a limit of 3,000. At 2,500 today and 8% monthly growth, you pass it in about 2.4 months. Keying a queue by customer breaks when one customer exceeds a single partition.
- How do you find the bottleneck from your estimates? Estimate every dependency on the path, including outside providers, and compare each limit with the demand. The part with the least headroom is the bottleneck. Fix it with caching, batching, queues, partitioning or rate limits, and then look for the next one.