🏗️ System Design

RESHADED framework + core building blocks

RESHADED Framework (45-60 min)

R
Requirements

Functional + non-functional. Users, scale, latency SLA

E
Estimation

DAU → QPS, storage, bandwidth. Back-of-envelope math

S
Storage Schema

SQL vs NoSQL. Data model, partition key, indexes

H
High-Level Design

Block diagram: clients, LB, services, DB, cache, queue

A
API Design

REST endpoints, auth, pagination, rate limiting

D
Detailed Design

Deep dive 1-2 critical components. Data flow

E
Evaluate

Single points of failure, bottlenecks, 10× scaling

D
Distinctive

Monitoring, CI/CD, gradual rollout, A/B testing

12 Core Concepts

Load Balancing

  • Round Robin
  • Least Connections
  • Consistent Hashing
  • L4 vs L7

Caching

  • Cache-Aside
  • Write-Through
  • Write-Behind
  • LRU/LFU
  • Redis / Memcached

Database Scaling

  • Read Replicas
  • Sharding
  • Denormalization
  • Connection Pooling

Message Queues

  • Point-to-Point
  • Pub/Sub
  • At-most/least/exactly-once
  • Kafka, SQS, RabbitMQ

CAP Theorem

  • CP: Strong consistency (Zookeeper)
  • AP: High availability (Cassandra)
  • Pick 2 of 3 in partition

Consistent Hashing

  • Hash ring
  • Virtual nodes
  • Minimal redistribution
  • Used in: DynamoDB, Cassandra

Rate Limiting

  • Token Bucket
  • Sliding Window Log
  • Sliding Window Counter
  • Fixed Window

CDN

  • Pull vs Push
  • Edge caching
  • CloudFront / Cloudflare
  • Static + dynamic content

Back-of-Envelope Numbers

Key Sizes

1 KB 1,024 bytes A short text
1 MB 1,048,576 bytes A photo
1 GB ~1 billion bytes A movie
QPS DAU × actions / 86,400 Peak = 2-3× avg
Storage/yr QPS × size × 86400 × 365 Plan 3-5 years
Memory 1M entries × 1KB = 1GB Fits in RAM

Latency Numbers

L1 cache ref 1 ns
L2 cache ref 4 ns
RAM ref 100 ns
SSD read (4KB) 150 μs
HDD seek 10 ms
Same DC round trip 0.5 ms
Cross-region 150 ms

Top 15 Problems by Tier

Tier 1
  • URL Shortener
  • Twitter Feed
  • Chat System
  • Rate Limiter
  • Notification Service
Tier 2
  • Key-Value Store
  • Web Crawler
  • YouTube
  • Uber/Lyft
  • Search Engine
Tier 3
  • Dropbox/GDrive
  • Instagram
  • Task Queue
  • E-commerce
  • Log Aggregation