โ๏ธ @amitmahata
1/10
System Design Framework & Fundamentals
โ
4-Step Senior System Design Framework (45 mins)
1. Clarify & Scope
โข Functional requirements
โข Non-functional (SLA/QPS)
โข Back-of-envelope math
(5 - 7 mins)
โข Non-functional (SLA/QPS)
โข Back-of-envelope math
(5 - 7 mins)
2. High-Level Flow
โข API contract (REST/gRPC)
โข Core DB schema entity
โข End-to-end block diagram
(10 - 15 mins)
โข Core DB schema entity
โข End-to-end block diagram
(10 - 15 mins)
3. Deep Dive Core
โข Scale bottlenecks
โข Cache / Sharding / Queue
โข Algorithms & data models
(15 - 20 mins)
โข Cache / Sharding / Queue
โข Algorithms & data models
(15 - 20 mins)
4. Bottlenecks & Scale
โข SPOF & Fault tolerance
โข Monitoring, SLOs, Tracing
โข Cost & trade-offs
(5 mins)
โข Monitoring, SLOs, Tracing
โข Cost & trade-offs
(5 mins)
โก
End-to-End Architecture Flow
๐ Client (Web/Mobile)
Anycast / GeoDNS
โ Static Assets & Edge Cache
โก CDN Edge Server (Cloudflare/CloudFront)
Edge PoP
โ Dynamic Requests
โ๏ธ L4/L7 Load Balancer (NGINX / ALB)
SSL / Health
โ Rate Limiting & Auth
๐ช API Gateway (Routing, Circuit Breaker)
Token Bucket
โ Internal Microservices
โ๏ธ App Services + Cache (Redis Cluster)
Cache-Aside
โ Async Events / DB Writes
๐๏ธ Primary/Replica DB + Kafka Queue
WAL / CDC
โข
Numbers Every 8+ YoE Engineer Must Know
โฑ๏ธ Latency Hierarchy (Orders of Magnitude)
- L1 cache reference: ~ 0.5 - 1 ns
- L2 cache reference: ~ 3 - 7 ns
- Main Memory (RAM) access: ~ 100 ns
- NVMe SSD random read: ~ 50 - 100 ยตs (1000x RAM)
- Read 1 MB sequentially from RAM: ~ 3 ยตs
- Read 1 MB sequentially from SSD: ~ 1 ms
- Datacenter network roundtrip (RTT): ~ 0.5 ms
- Intercontinental RTT (US โ EU): ~ 150 ms
๐ Back-of-Envelope Quick Multipliers
โข 1 Day = 86,400 s โ 100K seconds (for quick mental math)
โข 1 Million req/day โ 12 QPS | 100M req/day โ 1.2K QPS
โข Peak Traffic multiplier: Design for 2x to 5x of average QPS!
โข 1 Million req/day โ 12 QPS | 100M req/day โ 1.2K QPS
โข Peak Traffic multiplier: Design for 2x to 5x of average QPS!
โฃ
Availability & SLA Tiers
Availability Tiers (The "Nines")
99.0% ("2 Nines")3.65 days downtime / year
99.9% ("3 Nines")8.76 hours downtime / year
99.99% ("4 Nines")52.6 minutes downtime / year
99.999% ("5 Nines")5.26 minutes downtime / year (Telco/Fintech)
Key Reliability Metrics
MTBF (Mean Time Between Failures)System Uptime reliability
MTTR (Mean Time to Repair)Recovery speed & automated failover
RPO (Recovery Point Objective)Max acceptable data loss
RTO (Recovery Time Objective)Max acceptable downtime
โค
Napkin Math, Worked Out Like You Would on the Whiteboard
๐ข Powers of two
- 2ยนโฐ โ 1 thousand (KB)
- 2ยฒโฐ โ 1 million (MB)
- 2ยณโฐ โ 1 billion (GB)
- 2โดโฐ โ 1 trillion (TB)
๐๏ธ Ballpark per-node capacity
- Redis: ~100K simple ops/s
- Postgres primary: a few K writes/s
- Stateless app pod: 1โ5K RPS
- Kafka broker: 100+ MB/s
โ Ask before drawing
- Who are the users & how many?
- Read-heavy or write-heavy?
- Strong or eventual consistency?
- Latency target (p99)?
โญ Senior Takeaway
โ Never jump straight to drawing databases or Kafka topics! First establish Read-to-Write ratio (e.g., Twitter 100:1 vs Chat 1:1), storage size per record, and whether strong consistency is non-negotiable (e.g. Payments) or eventual consistency is acceptable (e.g. Likes, News Feed).
๐ก Staff / Senior Interview Tip
Q: How do you stand out as an 8+ YoE candidate in the first 10 minutes?
A: Don't wait for the interviewer to give you requirements. Actively drive the scope: "Assuming 50M DAU, each user making 20 requests daily yields ~12,000 QPS average, peaking at 35,000 QPS. At 500 bytes per payload, we'll store 500GB/day = 180TB over 5 years. I propose starting with an API Gateway + Cache-Aside architecture to offload 90% of reads."
A: Don't wait for the interviewer to give you requirements. Actively drive the scope: "Assuming 50M DAU, each user making 20 requests daily yields ~12,000 QPS average, peaking at 35,000 QPS. At 500 bytes per payload, we'll store 500GB/day = 180TB over 5 years. I propose starting with an API Gateway + Cache-Aside architecture to offload 90% of reads."