What system design actually is
System design is the skill of planning systems that stay fast, correct and alive as they grow from 100 users to 100 million. It is not about memorizing architectures. It is about making tradeoffs deliberately: every decision (SQL or NoSQL, sync or async, cache or no cache) buys you something and costs you something. Seniors are paid to know both sides of that exchange.
A useful mental model: a system is a pipe. Requests enter from users, flow through components (load balancer, app servers, caches, databases, queues), and responses flow back. Design is deciding what each component is, how big it needs to be, and what happens when it fails.
The journey of one request (with real numbers)
Ground every design in what a request actually costs. When you open instagram.com:
- DNS lookup: ~20-120 ms the first time, then cached.
- TLS handshake: 1-2 round trips (~50-100 ms cross-country), near zero with session resumption.
- Load balancer: under 1 ms of added latency; picks a healthy app server.
- App server: your code. A cache hit from RAM (Redis) is ~0.5-1 ms network + lookup. A database read is ~1-5 ms on an SSD. A spinning-disk seek is ~10 ms. Reading 1 MB sequentially from SSD is ~1 ms; from RAM, ~0.03 ms.
- Queue fan-out (async): emails, notifications, analytics happen after the response, so they add 0 ms to the user.
Memorize the shape of these numbers. "RAM is ~1000x faster than disk, in-datacenter calls are sub-millisecond, cross-continent round trips are ~150 ms" is enough to do every back-of-envelope estimate in an interview.
The interview framework (works for every question)
Interviewers grade process more than the final diagram. The standard flow:
- Clarify requirements (3-5 min): functional (what must it do?) and non-functional (how many users? read or write heavy? how available? latency budget?). Never start drawing before this.
- Back-of-envelope estimates (3 min): QPS, storage, bandwidth. Example: 100M daily users, 2 actions each, 86,400 seconds in a day: 200M / 86,400 is roughly 2,300 average QPS, 10x that at peak. 1 KB per action is ~200 GB/day of new data.
- API + data model (5 min): the 3-5 core endpoints and tables/collections.
- High-level design (10 min): clients, LB, app tier, storage, cache, queue. Boxes and arrows.
- Deep dive (15 min): the interviewer picks the hard part (feed generation, matching, locking). This is where the other 26 lessons on this site pay off.
- Scale + failure modes (5 min): "what breaks first at 10x? what happens when this box dies?"
Worked example: the same question, junior vs senior
Question: "Design a URL shortener." The junior answer jumps to code: "I'll hash the URL and store it in a map." The senior answer starts with scale: "How many new URLs per day, and how many redirects? Redirects are usually 100x creations, so this is read-heavy: I'll cache hot codes, pick a key generation strategy that avoids collisions on the write path, and decide between 301 and 302 based on whether analytics matter." Same system, completely different signal.
What goes wrong in production (failure modes to name)
- SPOFs: one LB, one DB, one queue consumer group. Every single box dies eventually; ask "and if this dies?" for each.
- Cascading failures: one slow service makes callers time out, retry, and amplify load until everything is down. Defenses: timeouts, circuit breakers, bounded queues, load shedding.
- Thundering herds: cache expiry or a deploy sends all traffic to the database at once.
- Hot spots: one celebrity user, one hot partition, one hot row gets all the traffic.
Common interview traps
- Drawing boxes before clarifying requirements and scale.
- Using buzzwords without numbers ("we'll just add Kafka") with no idea of the data rate.
- Designing for 1 billion users when the question said 100k, or the reverse.
- No failure story: everything works only on the happy path.
Interview Q&A
Q: How would you approach "design Twitter" in 45 minutes?
A: Spend the first 10 on requirements and estimates (DAU, tweets/day, read:write ratio), 5 on API and data model, 10 on the high-level diagram, 15 on the one hard piece (the feed: fan-out on write vs read), 5 on scale and failure modes. Saying this plan out loud in the first minute already separates you.
Q: What matters more, consistency or availability?
A: It depends on the feature, not the system: money balances need consistency, a like counter needs availability. Good designers answer per-feature, never globally.
System design asal mein hai kya
System design wo skill hai jisse tum aise systems plan karte ho jo 100 users se 100 million users tak fast, sahi aur zinda rahen. Ye architectures ratne ka naam nahi hai. Ye tradeoffs ko jaan-boojh kar lene ka naam hai: har decision (SQL ya NoSQL, sync ya async, cache ya nahi) kuch deta hai aur kuch leta hai. Senior engineers ko dono taraf jaanne ke paise milte hain.
Ek mental model: system ek pipe hai. Requests users se aati hain, components se guzarti hain (load balancer, app servers, caches, databases, queues), aur responses wapas jaati hain. Design ka matlab hai: har component kya hai, kitna bada chahiye, aur wo fail ho to kya hoga.
Ek request ka safar (asli numbers ke saath)
Har design ko request ki asli cost par rakho. Jab tum instagram.com kholte ho:
- DNS lookup: pehli baar ~20-120 ms, phir cache ho jaata hai.
- TLS handshake: 1-2 round trips (cross-country ~50-100 ms), session resumption se almost zero.
- Load balancer: 1 ms se bhi kam extra latency; healthy server chunta hai.
- App server: tumhara code. RAM se cache hit (Redis) ~0.5-1 ms. SSD se DB read ~1-5 ms. Spinning disk seek ~10 ms. 1 MB sequential read SSD se ~1 ms, RAM se ~0.03 ms.
- Queue (async kaam): email, notifications, analytics response ke baad hote hain, matlab user ko 0 ms extra.
Ye numbers yaad rakho. "RAM disk se ~1000x faster hai, datacenter ke andar calls sub-millisecond, cross-continent round trip ~150 ms", bas itna kaafi hai har back-of-envelope estimate ke liye.
Interview framework (har question par kaam karta hai)
Interviewer final diagram se zyada process grade karta hai. Standard flow:
- Requirements clear karo (3-5 min): functional (karna kya hai?) aur non-functional (kitne users? read-heavy ya write-heavy? kitni availability? latency budget?). Iske pehle drawing mat shuru karo.
- Estimates (3 min): QPS, storage, bandwidth. Example: 100M daily users, 2 actions each, din mein 86,400 seconds: 200M / 86,400 ≈ 2,300 average QPS, peak par 10x. Har action 1 KB ho to ~200 GB/day naya data.
- API + data model (5 min): 3-5 core endpoints aur tables/collections.
- High-level design (10 min): clients, LB, app tier, storage, cache, queue. Boxes aur arrows.
- Deep dive (15 min): interviewer hard part chunta hai (feed generation, matching, locking). Yahan is site ke baaki 26 lessons kaam aate hain.
- Scale + failure modes (5 min): "10x par pehle kya tootega? Ye box mar gaya to?"
Worked example: junior vs senior answer
Question: "URL shortener design karo." Junior seedha code par kudta hai: "URL ko hash karke map mein daal dunga." Senior scale se shuru karta hai: "Din mein kitne naye URLs aur kitne redirects? Redirects usually 100x hote hain, matlab read-heavy system: hot codes cache karunga, write path par collision-free key generation chununga, aur analytics chahiye ya nahi us hisaab se 301 vs 302 decide karunga." Same system, bilkul alag signal.
Production mein kya tootta hai (failure modes)
- SPOFs: ek LB, ek DB, ek queue consumer. Har box kabhi na kabhi marta hai; har box ke liye poochho "ye mar gaya to?"
- Cascading failures: ek slow service se callers timeout karte hain, retry karte hain, load double-triple ho jaata hai, sab down. Defense: timeouts, circuit breakers, bounded queues, load shedding.
- Thundering herd: cache expire hote hi ya deploy ke baad saara traffic ek saath database par.
- Hot spots: ek celebrity user, ek hot partition, ek hot row par saara traffic.
Common interview traps
- Requirements aur scale poochhe bina boxes banana shuru kar dena.
- Numbers ke bina buzzwords ("Kafka laga denge") aur data rate ka andaza hi na hona.
- Question 100k users ki ho aur design 1 billion ka, ya ulta.
- Koi failure story hi nahi: sab kuch sirf happy path par chalta hai.
Interview Q&A
Q: "Design Twitter" 45 minute mein kaise approach karoge?
A: Pehle 10 minute requirements aur estimates (DAU, tweets/day, read:write ratio), 5 minute API aur data model, 10 minute high-level diagram, 15 minute sabse hard piece par (feed: fan-out on write vs read), 5 minute scale aur failure modes. Ye plan pehle minute mein bol dena hi aadha interview jeetna hai.
Q: Consistency zyada important ya availability?
A: Feature par depend karta hai, system par nahi: money balance ko consistency chahiye, like counter ko availability. Acche designers per-feature jawab dete hain, globally kabhi nahi.