The interview framework: requirements, numbers and scope before boxes
Foundations F02. How a 45-minute system-design round is shaped, which questions to ask first, how to turn "fast" and "reliable" into numbers, which data must never be wrong, what to leave out, and how the requirements choose your deep dives. Each idea is told as a story you'll remember.
Start here
A system-design round gives you a vague prompt ("design WhatsApp") and about 45 minutes. The candidates who do well are rarely the ones who know the most boxes. They are the ones who first agree on what they're building, say how good it has to be in numbers, write down what they're leaving out, and then let those numbers pick the design.
This page is the method you'll use in every other page of the series: the shape of the round, the questions to ask, how to turn "fast" and "reliable" into numbers, and how those numbers choose your deep dives.
The caterer for a family wedding
A good wedding caterer doesn't start cooking the moment you call. They come home, sit with the family and ask.
- How many guests, and how many at the busiest hour of the reception? (scale)
- Which dishes are a must? Biryani, paneer, a sweet. (functional requirements)
- Food hot, served within 10 minutes of guests sitting, and nobody waiting more than 20? (non-functional requirements)
- Separate counters for Jain food? Food you can't get wrong, like the groom's family's allergies? (where you need strict correctness)
- "Decoration and the DJ are not our job." (out of scope)
- Then the menu card and the kitchen plan, and only then the hard part: two tandoors running non-stop when 800 people arrive at once. (high-level design, then deep dives)
An interview runs the same way. Each concept below is one question the caterer asks before lighting the stove.
The shape of the round: a 45-minute innings
Spend the first 5–10 minutes agreeing what to build and how good it must be, sketch the whole system next, and save the biggest block of time for 1–2 deep dives the requirements point to.
Pacing a T20 innings
A T20 batter doesn't swing at every ball from the first over, and doesn't play defensively until the 18th either. There's a plan: powerplay, middle overs, death overs.
A batter who spends 15 overs "getting set" runs out of balls. A batter who slogs from ball one gets out early. The round is the same: too long on requirements and you never reach the interesting part; too little and you design the wrong system very well.
A typical 45-minute round, in order:
- Requirements and scope (5–10 min): functional, non-functional, out of scope. Write them down.
- Core entities and API (about 5–7 min): the nouns, and 3–5 calls that serve the functional requirements.
- High-level design (10–15 min): boxes and arrows that satisfy every functional requirement, end to end.
- Deep dives (10–15 min): the 1–2 places where the non-functional requirements make the design hard.
- Wrap-up (2–3 min): bottlenecks, what fails first, what you'd do next.
Estimation (QPS, storage) is not a fixed step. Do the math when a number will change a decision, not as a ritual; that's the next Foundations page.
Public prep frameworks agree on the outline, with small differences. ByteByteGo's 4 steps budget 3–10 minutes for scope, 10–15 for the high-level design, 10–25 for deep dives and 3–5 to wrap up. Hello Interview budgets about 5 minutes for requirements and suggests skipping up-front estimation unless it changes the design (both third party, checked Oct 2026).
The Uber deep-dive in Part 01 follows this exact order, so you can rehearse it top to bottom.
- A fixed time plan keeps you moving, but follow the interviewer: if they steer you to a deep dive early, go.
- Interviewers at some companies want estimation up front; ask "should I size it now or as we go?" rather than guessing.
I'll spend a few minutes pinning down requirements and scale, sketch the full flow, then go deep on the parts that are hardest given those requirements. Stop me if you'd like a different focus.
Running out of time before any deep dive. A complete but shallow design reads as mid-level, however polished the boxes are.
Clarifying questions: measure before you cut
Ask a few sharp questions about who uses it, what they do, how big it is and how good it must be, then write your assumptions down so the interviewer can correct them.
The darzi with the measuring tape
A good tailor never starts cutting cloth from "make me a kurta". Wedding or office? Slim or loose? Ready by when? He measures twice, writes the numbers in his notebook and reads them back to you.
He also doesn't measure your earlobes. Ten good questions, not fifty. And when you don't know ("whatever is normal"), he picks the normal and tells you what he picked.
Four groups of questions cover most prompts:
- Who and what: who are the users, and what are the 2–3 things they must be able to do?
- How big: users, actions per user, data size, read-heavy or write-heavy, global or one country?
- How good: how fast (at the 99th percentile), how available, can any data be lost, can anyone see stale data?
- What's not in: features, clients or teams we can leave out.
If the interviewer says "you decide", decide out loud: "I'll assume 50M daily users in India, mostly reads."
"Design WhatsApp" can mean very different systems. Five questions change the design:
- 1:1 only, or groups? How big can a group be? (fan-out on send)
- Text only, or media? (blob storage and a CDN)
- Delivery and read receipts? (per-message state)
- Must messages reach offline users later? (store-and-forward)
- End-to-end encryption in scope? (the server can't read or search messages)
Each answer adds or removes whole boxes; that is why they come first.
- More questions reduce the risk of solving the wrong problem but eat the clock; aim for 3–5 minutes.
- Ask questions whose answers change the design. If both answers lead to the same diagram, skip it.
Before I design, let me check a few things that change the architecture: group size, media, offline delivery and scale. I'll write my assumptions on the board.
Interrogating the interviewer with a memorised 20-question checklist. Questions should come from the problem, and you should be ready to assume and move on.
Functional requirements: the three dishes you'll cook well
Functional requirements are what users can do, written as "users can…"; pick the top three and design for those, not for every feature the product has.
The highway dhaba
The best highway dhabas don't have 200 items. They have dal, roti, paneer and chai, cooked fast and the same every time. Truckers stop because of that.
A restaurant that promises everything on a 12-page menu serves most of it badly. In an interview you have one kitchen and 45 minutes. Choose the dishes.
Write each requirement as a user action:
- "Riders can see a fare and request a ride."
- "Drivers can accept a nearby request."
- "Riders can see the driver approach in real time."
Then prioritise: mark the top 3 as "core", the rest as "if time". Core requirements are what your high-level design must satisfy end to end; nothing else must.
Part 01 (Uber) writes four short lines: the rider sees a fare and nearby cars; the rider requests and one driver is matched within seconds; the driver accepts and both see live tracking; either side cancels, or the trip completes and the rider pays. Onboarding, ratings, support tooling and building maps are named and parked.
Each line later becomes one or two API calls and one path through the diagram, and the hard part (matching within seconds) is visible from the list itself.
- Fewer requirements mean more depth; more requirements mean a broader but thinner design. Senior rounds reward depth.
- If the interviewer insists on a feature you parked, add it; that's a signal of what they want to probe.
The core is: see a fare and request, match one nearby driver within seconds, and live tracking. Ratings and onboarding I'll park unless you want them.
Listing ten features and then designing none of them properly. Or the opposite: never writing them down, so the interviewer can't tell what you're solving.
Non-functional requirements: "fast" is not a number
Non-functional requirements say how well the system must work, and they only help if they're numbers: latency at a percentile, availability as a success rate, how much data you may lose, how stale reads can be.
"30 minutes or it's free"
"We deliver fast" is a slogan. "30 minutes or the pizza is free" is a requirement: it has a number, a way to measure it and a cost if you miss it.
And notice it isn't "30 minutes on average". If half the pizzas arrive in 10 minutes and half in 50, the average looks great and half the customers eat for free. Promises are about almost every order, not the average one.
Turn each quality into a number you could measure:
- Latency: "p99 under 300 ms" (99 out of 100 requests are faster), not "fast". Averages hide the slow tail.
- Availability: "99.9% of requests succeed over 30 days". Each extra nine is 10× less room for failure.
- Durability: "no confirmed message is ever lost" (RPO = 0) vs "a few seconds of loss is fine".
- Consistency: can a user see stale data, and for how long?
- Scale: peak requests per second, data growth per year.
The words: an SLI is what you measure (the share of requests under 300 ms), an SLO is the target (99%), an SLA is a promise to customers with a penalty (the free pizza).
Amazon's Dynamo paper (2007) describes service targets written exactly this way: respond within 300 ms for 99.9% of requests at a peak of 500 requests per second. Amazon chose the 99.9th percentile over the mean because averages hide the slowest requests, and those often belong to customers with the longest histories, whose pages need the most work.
Latency has a price you can measure: Google's 2009 experiment added 100–400 ms to search results and saw searches per user drop by 0.2–0.6%; at 400 ms, users still searched less weeks after the delay was removed.
- Tighter latency targets push you to caches, precomputation and fewer hops, which cost freshness and money.
- Higher availability needs redundancy everywhere and automatic failover; the cost of each extra nine grows much faster than its benefit.
Let me put numbers on it: p99 under 200 ms for reading messages, 99.99% availability for sending, and once the server acks a message it is never lost.
Saying "highly available, low latency, scalable" and moving on. Every system wants that; without numbers they can't drive a single decision.
Availability and the price of each nine
An availability target is a downtime budget: 99.9% allows about 8.8 hours a year, 99.99% about 53 minutes, and you can never be more available than the chain of services you depend on.
Power cuts and the inverter
Think of the electricity at home. "We get power 99% of the time" sounds good until you work it out: over three and a half days without power a year.
Most homes in India solve the last bit with an inverter, not by asking the grid for perfection. And if your house needs the grid, the inverter and the wiring all to work, your power is only as good as the weakest of them. Systems work the same way.
- Downtime budget = (1 − target) × time. A year has 525,600 minutes, so 99.9% allows 526 minutes (8.76 hours) and 99.99% allows 52.6 minutes.
- Large services usually measure it per request: successful requests ÷ all requests over a window.
- Dependencies multiply. If a request needs 4 services that are each 99.9% available, the best you can do is 0.999⁴ ≈ 99.6%.
- Recovery speed matters as much as failure rate: a budget of 52 minutes fits only one or two 30-minute incidents a year, so humans can't be in the recovery path.
Google's SRE book gives the arithmetic: at 99.99%, a service may be down for up to 52.56 minutes a year; measured per request, a service handling 2.5M requests a day can fail 250 of them and still meet its daily target.
It also makes the economic point interviewers like: moving from 99.9% to 99.99% adds 0.09% of availability. On a service earning $1M, that's worth about $900; if the extra nine costs more to build and run, don't build it.
- Pick the target per feature: "send message" may need 99.99%; "edit profile photo" can live with 99.9%.
- More nines mean multiple zones or regions, automatic failover and slower, safer deploys. Ask what an hour of downtime costs before buying them.
99.99% gives us about 52 minutes a year, so recovery has to be automatic. And with four hard dependencies at 99.9% each, we'd cap at 99.6%, so two of them must become optional.
Promising five nines (about 5 minutes a year) for a product that clearly doesn't need it, or quoting nines without saying what's measured.
Try it: What does a requirement really cost?
Pick an availability target and see the downtime budget, how many incidents fit, what your dependency chain allows, and why the p99 matters when one page calls many servers.
| What we're sizing | Number | How we got it | So we decide |
|---|---|---|---|
| 1 · What the target allows | |||
| Downtime budgetEvery extra nine cuts the allowed downtime by 10×, and engineering cost rises much faster than that. | 52.6 min / year | 1 − 99.99% = 0.01% of the time 525,600 min/year × 0.01% = 52.6 min per month: 43,800 min × 0.01% = 4.4 min | This needs redundancy in every layer (several zones, no single database primary without fast failover). Ask whether the business needs it. |
| Failed requests allowedBig services count availability as successful requests ÷ all requests, not minutes of uptime. Same idea, measured per request. | 1,000 / day | 10,000,000 requests × 0.01% = 1,000 errors | State the target as a success rate over a window (e.g. 99.9% of requests over 30 days), which you can actually measure. |
| Incidents you can affordHow fast you recover matters as much as how rarely you fail. | 1.8 / year | 52.6 min ÷ 30 min per incident = 1.8 incidents | Only a handful of incidents a year. Plan automatic failover and canary deploys; paging a human for each failure will use up the budget. |
| 2 · You can't beat your dependencies | |||
| Hard dependencies in a chain | |||
| Best case for the whole requestIf a request needs every one of them, their failures add up. Your service is never more available than its chain. | 99.601% | 99.9% ^ 4 = 99.601% target 99.99% → missed | The chain alone misses the target. Make some calls optional (degrade gracefully), cache their answers, or add redundant copies of the weakest link. |
| 3 · Why we ask for p99, not the average | |||
| One page calls many backends in parallelEach backend is slow on 1 call in 100 (that's what its p99 means). | |||
| Pages that wait on a slow callThe page is as slow as its slowest call. Rare slowness on each server becomes common slowness for users. | 18.2% | 1 − 0.99 ^ 20 = 18.2% | Fan-out is modest; a p99 target per hop with sensible timeouts is enough. |
Try: move from 99.9% to 99.99% and watch "incidents you can afford" fall below 4. Then set 100 backends: 63% of pages hit a slow call, the figure from Dean and Barroso's "The Tail at Scale". Months are averaged (43,800 min); numbers are rounded for teaching.
Which data must never be wrong?
Decide, per piece of data, whether a slightly stale or briefly conflicting answer is acceptable; that one choice decides your databases, locks and failover more than anything else.
The Tatkal seat vs the "seats left" counter
When you book a Tatkal ticket, the seat itself must never be sold twice. If two people press "Pay" for the last berth at the same moment, exactly one gets it.
But the "Available: 12" number you saw a second earlier can be a little old. Nobody is harmed if it said 12 when it was really 9. Same train, same screen: one number must be exact, the other only needs to be recent.
For each kind of data, ask two questions:
- Can a reader see a slightly old value? (Feeds, counts, profiles: usually yes. Balances, inventory, seat holds: no.)
- When the network splits, do we refuse the request or answer with what we have?
That second question is the honest version of CAP: during a network partition, a replicated system must either reject some requests (stay consistent) or answer with possibly stale data (stay available). When there is no partition, the trade-off is latency vs consistency. CAP is a choice you make per operation, not a label for a whole database. The Consistency page goes deeper.
Amazon designed Dynamo so the shopping cart is "always writeable": customers can add items even while disks fail and network routes flap, and conflicting versions are merged later. Losing an "add to cart" was worse than showing a briefly odd cart.
The opposite failure: on Flipkart's first Big Billion Day (Oct 2014), simultaneous buying created orders for items that had already sold out, and the founders publicly apologised for the cancellations. Inventory is data that must not be oversold.
- Strong consistency is simpler to reason about, but costs latency (a leader or quorum on each write) and availability during failures.
- Eventual consistency stays fast and available, but you must design for conflicts and tell users what they might see.
Seat holds and payments need strong consistency, so one leader per partition and conditional writes. Search results and seat counts can be a few seconds stale, so they come from caches and replicas.
Saying "I'll choose AP" or "CP" for the whole system. Real systems choose per operation, and CAP only bites during a partition.
Scale and the shape of the load
Four numbers shape most designs: how many users, how many reads per write, how high the peak is compared with the average, and how fast the data grows.
The kirana shop at Diwali
A neighbourhood kirana shop is fine with one counter on a normal Tuesday. In the week before Diwali, the same customers come, but all at once, and they ask "do you have it?" ten times for every thing they buy.
The shopkeeper doesn't build a counter for every day of the year. He plans for the rush, puts the popular items near the front (a cache) and keeps the price list on the wall so people stop asking (reads served without the cashier).
- Users: daily active users and what one user does per day.
- Read:write ratio: many systems read far more than they write, which points to caches and replicas. Some (logging, metrics, location updates) are write-heavy, which points to append-friendly storage and partitioning.
- Peak vs average: traffic is not flat. Design for the peak (often several times the average, far more for sales and launches).
- Growth: data per day × retention, so you know whether it fits on one machine.
You don't need exact figures in this step; you need the order of magnitude and the ratios. The arithmetic is the next page.
Indian Railways' upgraded reservation system is specified for more than 1.5 lakh bookings and 40 lakh enquiries a minute, up from about 32,000 bookings and 4 lakh enquiries (PIB, Aug 2026). That's roughly 27 enquiries for every booking at peak: a read-heavy front with a small, strictly consistent booking core.
Peaks surprise even well-prepared teams: for Big Billion Day 2014 Flipkart said it had deployed nearly 5,000 servers and prepared for 20× the expected traffic, and demand at times was still higher.
- Designing for a huge peak you'll see once a year is expensive; autoscaling, queues and a waiting room can absorb it more cheaply.
- A read-heavy system wants caches and replicas; a write-heavy one wants partitioning and batching. Getting the ratio wrong points you at the wrong deep dive.
Roughly 100M daily users, about 20 reads per write, and a peak around 5× the average on festival days. So reads come from caches and replicas, and the write path is where I'll go deep.
Producing a page of precise arithmetic and then never using it. Every number you compute should end in a decision.
Out of scope and assumptions: draw the boundary
Say out loud what you're not building and what you're assuming, and write it where the interviewer can see it; it protects your time and shows judgement.
The painter's quotation
A good painter's quote says: "Walls and ceilings of 3 rooms, two coats, Asian Paints. Excludes window grills, furniture polish and wall repairs."
Nobody argues later, because the boundary was written down. If you want the grills done, you ask, and the price and time change. Everybody knows what "done" means.
Write three short lists next to your requirements:
- Out of scope: features (payments, admin tools), clients (web, if mobile-first), concerns another team owns (fraud, ML ranking).
- Assumptions: numbers you picked ("50M DAU, India first"), things you take as given ("an auth service exists").
- Later: what you'd add with more time, so the interviewer sees you know it exists.
Out of scope isn't "ignored". It's a decision you can revisit when the interviewer asks.
In a ride-hailing round, a sensible boundary is: ratings, driver onboarding, support tooling and building the maps themselves are out; one country, mobile clients only; an identity service exists. That leaves time for the hard parts: finding nearby drivers fast and matching without double-assigning one driver.
- Cutting scope gives depth, but cut what's peripheral, not what's hard. Removing the hard part to make the design easy is noticed.
- Assumptions keep you moving, but unstated assumptions look like gaps; state them.
I'll leave ratings, onboarding and admin tools out, assume one country and an existing auth service, and come back to them if we have time.
Declaring the hard problem out of scope ("assume matching is handled by another service"). That is the interview.
Let the requirements pick the design
Satisfy the functional requirements with a simple end-to-end design first, then go deep exactly where a non-functional requirement makes that simple design break.
Google Maps before a long drive
Before a drive from Bengaluru to Mysuru, you look at the whole route first: which highway, roughly how long. You don't start by zooming into one junction.
Then you zoom in where it matters: the flyover where the app always gets confused, the stretch with traffic at 6 pm. The overview gets you there; the zoom-ins are where you save the hour.
- Core entities: the nouns (User, Ride, Driver, Location). A minute, not a schema.
- API: one or two calls per functional requirement. This proves your design does what users need.
- High-level design: simple boxes that make every functional requirement work end to end. No optimisation yet.
- Deep dives: walk your non-functional list and ask "where does the simple design break?" "p99 under 200 ms at 50K reads a second" breaks a single database: caching. "Never double-book a seat" breaks naive writes: locks or conditional updates.
- Wrap-up: the biggest risk left, what fails first, what you'd measure.
At Senior level you're expected to pick the deep dives yourself and explain why; at Staff level, also to say which requirements you'd challenge.
In Part 01, two lines do the choosing. "Tap to offer on the driver's phone in under 1 s (p95)" while every active driver sends a location every 4 seconds (about 1M writes a second at peak) breaks a plain database query, which justifies the deep dive into an in-memory geo index. "Ride state and payments: never duplicated" justifies the deep dive into matching one driver to one ride. Every deep dive should trace back to a line like these.
- Optimising during the high-level design wastes time on parts that may not matter; but name obvious needs (a cache, a queue) as you go.
- Follow the interviewer's hints over your plan: "what if this gets 10× traffic?" is telling you which deep dive they want.
That covers the functional flow. Looking at the non-functional list, the hard ones are the 200 ms read target and no double-booking, so I'll go deep on those two.
Choosing deep dives by what you know best ("let me explain Kafka") instead of what the requirements make hard.
Remember it
One line per idea. Read this the night before.
- The round is a T20 innings: 5–10 min requirements, a full sketch, then most of the time on 1–2 deep dives.
- The darzi measures before he cuts: ask the few questions whose answers change the design, then state assumptions.
- The dhaba cooks three dishes well: write "users can…", keep three core requirements, park the rest.
- "30 minutes or it's free": non-functional requirements are numbers, at a percentile, with a way to measure them.
- Each nine is 10× less downtime: 99.9% ≈ 8.8 h a year, 99.99% ≈ 53 min; a chain is never better than its links.
- The Tatkal seat must be exact; the "seats left" counter can be stale. Choose consistency per piece of data.
- The kirana at Diwali: users, read:write ratio, peak vs average, growth. Design for the rush.
- The painter's quote: write what's out of scope and what you assume, but never cut the hard part.
- Maps before a drive: simple end-to-end first, then zoom in where a non-functional requirement breaks it.
Check yourself
Answer out loud, then open.
You're 20 minutes in and still discussing requirements. What went wrong, and how do you recover?
You asked questions whose answers didn't change the design, or didn't commit to assumptions.
- Summarise what you have in one line each (functional, non-functional, out of scope).
- State the remaining unknowns as assumptions and move to the high-level design.
- Protect at least 10 minutes for one deep dive.
Say it Let me lock these in as assumptions so we have time for the hard parts.
The interviewer says "it should be fast". What do you write down?
A number at a percentile, for a specific operation: for example "p99 under 200 ms for loading the chat list, p99 under 500 ms for sending".
Averages hide the slow tail; a percentile says what almost every user sees. Then ask if anything else (search, uploads) has a different target.
Your service targets 99.99%. It calls 3 services, each 99.9%, all required. Is the target realistic?
No. Required dependencies multiply: 0.999³ ≈ 99.7%, below 99.99%, before your own failures.
- Make some calls optional (degrade: show the page without that part).
- Cache their answers or move them off the request path (async).
- Ask whether 99.99% is needed for this operation at all.
Someone says "we'll choose AP" for an e-commerce site. What's the more precise answer?
Choose per operation, and remember CAP only forces a choice during a network partition.
- Browse, search, recommendations, cart: stay available and accept some staleness.
- Inventory decrement, payment, order placement: stay consistent; reject or queue the request rather than oversell.
Without a partition, the trade-off is latency vs consistency.
What makes a deep dive a good choice?
It traces back to a requirement that breaks the simple design: a latency target the database can't meet, a correctness rule (no double-booking) that naive writes violate, or a scale number one machine can't hold.
A deep dive picked because you know the technology well, with no requirement behind it, is a weak choice.
What should go in "out of scope", and what must never go there?
Peripheral features (payments in a ride app, admin tools), other teams' concerns (fraud, ML ranking) and extra clients can go. Write them down so you can return to them.
The core hard problem must stay in: matching for Uber, fan-out for a feed, seat holds for ticketing. Removing it removes the interview.
Where you'll use this in the series
- Uber: from tap to pickup · three core requirements, numbers that pick the geo deep dive
- How a request travels · latency budgets in round trips
- Back-of-envelope estimation · turning scale into QPS, storage and machines (coming)
- Consistency, CAP and quorums · the per-operation consistency choice, in depth
- Ticketmaster: selling seats without double-booking · a correctness requirement that drives the whole design (coming)
Sources
- Embracing Risk, Site Reliability Engineering (Google, 2016)
- Service Level Objectives, Site Reliability Engineering (Google, 2016)
- Dynamo: Amazon's Highly Available Key-value Store, SOSP (Oct 2007)
- The Tail at Scale, Dean and Barroso, Communications of the ACM (Feb 2013)
- Speed Matters, Google Research blog (Jun 2009)
- From Queues to Clicks: four decades of passenger reservation in Indian Railways, PIB (Aug 2026)
- "We Are Really & Truly Sorry", Flipkart founders on Big Billion Day, Inc42 (Oct 2014)
- A framework for system design interviews, ByteByteGo (third party, checked Oct 2026)
- Delivery framework, Hello Interview (third party, checked Oct 2026)
Checked October 2026. Availability and SLO arithmetic follows the Google SRE book; company figures are as published on the dates shown (the Indian Railways figures are design capacity, not measured load). The time splits come from third-party prep frameworks and are a guide, not a rule.
System Design Mastermind · Foundations
Series homeAll of Foundations
18 publishedStart here: the concepts every design uses, each told as a story you'll remember.
How a request travels: DNS, load balancers, gateways and open connections
Name → address (DNS) → open a secure line once and reuse it (TCP, TLS) → nearby copies for static files (CDN) → spread and guard the work (load balancer, gateway) → find colleagues inside (discovery) → keep a line open for live updates.
The interview framework: requirements, numbers and scope before boxes
Agree what users must do (three core requirements) → put numbers on how well (p99 latency, availability, durability, staleness) → say what's out of scope → sketch the simple end-to-end design → go deep only where a number breaks it.
Back-of-envelope estimation: from users to servers in one minute
Users × actions ÷ 86,400 (≈10⁵) = average per second → × peak factor → split reads and writes → storage = count × size × time × copies → bandwidth × 8 bits → in flight = rate × latency → servers = peak ÷ (capacity × 60%) + 2 spares.
APIs and real-time communication: REST, gRPC, retries, webhooks and live updates
Nouns + HTTP verbs (user from the token) → REST outside, gRPC inside → cursor pagination → POST with an Idempotency-Key, retries with backoff and jitter → add, don't change → poll for rare updates, SSE for one-way live, WebSockets for both ways → webhooks are at-least-once → thin connection gateways with resume and push fallback.
Databases: data models, indexes and transactions
Relational by default (each fact once, keys, constraints) → key-value / document / wide-column / graph only for a named access pattern → B-tree for reads, LSM for heavy writes → composite index with equality columns first, then the sort → one transaction per local change, made durable by the write-ahead log → know your isolation level → win races with a conditional write and a unique constraint.
Replication and sharding: copying and splitting your data
Copies scale reads and survive failures (leader + followers); splits scale writes and size (shards). Replicate first; shard only when data size or write rate outgrows one leader → pick the shard key from the main query → hash it into many fixed slots so growth moves ~1/(N+1) → name your hot key and your one cross-shard query.
Caching: hit ratios, invalidation and stampedes
Cache what is read far more than it changes → say the expected hit ratio and size the database for the misses → cache-aside with a TTL; on writes, update the database then delete the key → coalesce misses on hot keys and jitter TTLs → plan for the cache failing or restarting empty, because by then the system depends on it.
Consistency, CAP and quorums: what replicas promise
Say what each operation needs, not what the system is: strong (linearizable) for money, stock, seats and uniqueness; read-your-writes for a user's own data; eventual for counts, feeds and pages → during a partition, strong operations fail on the minority side, the rest keep serving (CAP) → on a normal day, strong costs a round trip to a quorum (PACELC) → with N copies, W + R > N makes reads overlap the latest write, but it isn't linearizability.
Coordination: clocks, leaders, locks and consensus
Don't order events across machines by wall-clock time; let one leader assign the order → elect that leader by majority vote with increasing terms, so a split network can't elect two → give it a lease so a dead leader is replaced without anyone proving it died → and a fencing token the storage checks, so a paused old leader can't do harm → use consensus (Raft) for the few decisions that must be agreed, not for every request.
Queues and event streams
Put a queue between work that can wait and the caller, so a spike becomes lag instead of an outage → use a task queue for jobs and an event log (Kafka) when many consumers need every event, replay or per-key order → key by the entity whose order matters and size partitions for peak consumers → deliver at least once and make consumers idempotent → retry a few times with backoff, then dead-letter → scale on lag → publish through an outbox, never "save, then publish".
Idempotency, exactly-once and sagas
Treat a timeout as unknown, never as failed → make writes idempotent by design (set, don't add; client IDs; conditional writes) → for the rest, an idempotency key per intent, stored with the result in the same transaction as the effect → consumers deduplicate by message ID in the same transaction → exactly-once holds only inside one boundary → across services, use a saga of local steps with compensations, not 2PC → compensable steps first, the pivot (capture payment) next, retryable steps last, on a durable orchestrator.
Scaling and performance
State latency as a percentile at a stated load → size each tier to the utilisation where its p99 is still flat (pooled, least-request balancing lets you run hotter) → budget fan-out calls against the page deadline, hedge stragglers → scale up first, scale out stateless tiers → name the shared resource (database, lock, connections) that caps the speed-up → find the saturated resource and cut work per request → pre-scale known peaks, autoscale on the signal that saturates → under overload, shed the lowest-priority work fast and budget retries.
Reliability and disaster recovery
Turn the target into a downtime budget → cut hard dependencies, because chains multiply → spread copies across zones (cells for blast radius) → timeouts from the deadline, one layer of jittered retries under a budget → circuit breakers with fallbacks and a bulkhead per dependency → fast, non-flapping health checks (readiness checks dependencies, liveness doesn't) → statically stable: spare capacity already running, config cached → PITR plus tested restores, because replicas copy mistakes → the cheapest DR strategy that meets RTO and RPO, drilled.
Observability and safe deployments
Metrics to notice, traces to locate, logs to explain (joined by a trace ID) → watch latency percentiles, traffic, errors and saturation → set an SLO per user journey and treat 1 − SLO as an error budget → page on burn rate over two windows, not on CPU → canary every change on a slice with automated analysis against a baseline → keep every version compatible with its neighbours (expand, migrate, contract) so rollback is always possible → ship dark behind flags, and stage config like code → when it breaks: one commander, mitigate first, blameless postmortem.
Security essentials for system design
Prove who the caller is (slow salted hashes, MFA, passkeys, rate-limited login) → carry identity in short-lived signed tokens with revocable refresh tokens, or in sessions you look up → delegate with OAuth code flow + PKCE, sign in with OpenID Connect → check this user against this object on every request, least privilege for people and services, audit logs → TLS 1.3 at the edge, mTLS inside, no trust from network location → envelope encryption with a KMS, secrets in a vault, tokenise what you needn't keep → treat all input as data (parameterise, encode, CSRF tokens, no user-chosen fetches) → absorb floods and abuse at the edge.
Search, feeds and geo building blocks
Search: analyse text into terms → inverted index of sorted postings → BM25 or hybrid (BM25 + vectors via RRF) retrieval of ~1,000 candidates → learned ranker → shards with replicas, fed from the database by CDC, refreshed every second. Typeahead: precomputed top-k per prefix in memory. Feeds: push IDs into followers' timelines, pull celebrities at read time, hydrate, filter, rank, page with cursors. Geo: index by cell (geohash, S2, H3), search the cell plus neighbours, exact distance on the few candidates.
Data pipelines: batch and stream
Pick batch or stream by how fresh each output must be. Get data in with log-based CDC (snapshot, then the WAL) and schemas that evolve safely; land raw events as Parquet in lakehouse tables partitioned by date. Batch jobs map, shuffle and reduce one partition and overwrite it, so retries and backfills are safe. Stream jobs window by event time, fire on watermarks, decide whether late events wait, correct or drop, and checkpoint state with offsets for exactly-once effect, with transactional or idempotent sinks. Reprocess by replaying retained data (Kappa) rather than keeping two codebases (Lambda).
AI foundations: inference, RAG and agents
Latency is time to first token (prefill reads the prompt, compute-bound) plus output tokens × time per token (decode, memory-bound), so stream answers and limit by tokens. GPU memory is weights plus a KV cache per request; long prompts, not users, fill it. Continuous batching shares each weight read across many requests, cutting cost per token by 10× or more until time per token hits its target. Route easy requests to small models, cache shared prompt prefixes, quantize carefully. RAG retrieves, reranks and cites a few permission-filtered chunks; agents are tool-calling loops with budgets, idempotent tools and approval for irreversible steps. Evaluate every change on an eval set, and design so a model fooled by prompt injection still can't do damage.