KASHII UPDATEZ Everyday Student Requirements & Python Coding Tutorials by Python Kashi
KashiiUpdatez
← Back to Tech Blog

System Design Interview: Designing Twitter Feed, WhatsApp & YouTube Architecture

Step-by-step system design walkthroughs for FAANG interviews. Learn how to design scalable distributed systems for Twitter's news feed, WhatsApp's messaging, and YouTube's video pipeline with CAP theorem, consistent hashing, and sharding explained.

Kashinath Chavan
Kashinath Chavan
Interview Prep & Database ⏱️ 5 min read Aug 22, 2026
Follow β†—
System Design Interview: Designing Twitter Feed, WhatsApp & YouTube Architecture

The System Design Interview Framework

System design interviews test your ability to break down ambiguous requirements, identify bottlenecks, and make justified trade-offs. Every strong answer follows this structure: Clarify → Estimate → Design → Deep Dive → Trade-offs.

PhaseDurationGoal
1. Clarify Requirements5 minScope the problem: DAU, QPS, features in/out
2. Capacity Estimation5 minStorage, bandwidth, read/write ratio
3. High-Level Design10 minComponents, APIs, data flow
4. Deep Dive15 minPick 2-3 hard problems and solve them
5. Trade-offs5 minJustify choices, discuss alternatives

1. Design Twitter's News Feed

Scale Numbers

Writes: 5M tweets/day = ~60 QPS (peak 3x = 180 QPS)
Reads:  600M/day      = ~7,000 QPS (peak = 21,000 QPS)
Storage: avg tweet = 280 chars = ~1 KB
         5M * 1 KB = 5 GB/day => ~1.8 TB/year (text only)
         Images:  ~30% of tweets, avg 500 KB
                  1.5M * 500 KB = 750 GB/day => CDN required

Feed Generation: Pull vs Push vs Hybrid

StrategyWrite CostRead CostBest For
Pull (fan-out on read)LowHigh β€” query all followeesCelebrities (millions of followers)
Push (fan-out on write)High β€” write to all followersLowRegular users (<10K followers)
HybridMediumLowTwitter's actual approach

Twitter's Hybrid Approach

  1. When a tweet is posted, push to all followers who have fewer than 10K followers (regular users).
  2. For celebrities (10K+ followers), do not pre-push. Fetch their latest tweets at read time and merge.
  3. Timelines stored in Redis (sorted set by timestamp), capped at 800 tweets.
@celery_app.task
def fanout_tweet(tweet_id: str, author_id: str):
    tweet = Tweet.objects.get(id=tweet_id)
    followers = Follower.objects.filter(followee_id=author_id).values_list('follower_id', flat=True)

    pipe = redis.pipeline(transaction=False)
    for follower_id in followers:
        if get_follower_count(follower_id) < 10_000:
            timeline_key = f"timeline:{follower_id}"
            pipe.zadd(timeline_key, {tweet_id: tweet.created_at.timestamp()})
            pipe.zremrangebyrank(timeline_key, 0, -801)  # Keep only latest 800
    pipe.execute()

2. Design WhatsApp Messaging

Core Challenges

Message Delivery States

WhatsApp uses a 3-state model: SENT (single tick), DELIVERED (double tick), READ (blue double tick). Each state requires an ACK from the recipient back to the sender.

CREATE TABLE messages (
    id          UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    chat_id     UUID NOT NULL REFERENCES chats(id),
    sender_id   UUID NOT NULL,
    content     BYTEA NOT NULL,           -- encrypted blob
    seq_num     BIGINT NOT NULL,          -- monotonic per chat
    status      SMALLINT DEFAULT 0,       -- 0=sent, 1=delivered, 2=read
    created_at  TIMESTAMPTZ DEFAULT NOW(),
    UNIQUE (chat_id, seq_num)             -- ordering guarantee
);
CREATE INDEX idx_messages_chat_seq ON messages(chat_id, seq_num DESC);

3. Design YouTube's Video Pipeline

The Two Hard Problems

  1. Upload and transcoding: A 4K 30-minute video is ~12 GB. Transcode into 8 quality levels (360p through 4K) in parallel.
  2. Adaptive bitrate streaming: Serve the right quality based on bandwidth, switching seamlessly mid-stream.
Client -> Upload Service (resumable chunked upload)
               |
         Raw Video Storage (S3/GCS)
               |
     Transcoding Job Queue (SQS/Kafka)
               |
     Transcoding Workers (FFmpeg, GPU farm)
       /          |          \
  360p.mp4  720p.mp4  1080p.mp4  ... (8 variants)
               |
    CDN (CloudFront/Akamai)
               |
         Client (HLS/DASH adaptive streaming)
# master.m3u8 β€” tells the player which variants exist
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360
360p/playlist.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2800000,RESOLUTION=1280x720
720p/playlist.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=5000000,RESOLUTION=1920x1080
1080p/playlist.m3u8

Key Distributed Systems Concepts

ConceptWhat It SolvesKey Trade-off
Consistent HashingDistribute keys across nodes, minimise re-hashingSlight uneven distribution without virtual nodes
CAP TheoremGuarantee 2 of: Consistency, Availability, Partition toleranceDistributed systems must choose CP or AP
Write-Ahead Log (WAL)Durability: recover from crashes without data lossAdds write latency
Read ReplicasScale reads horizontallyReplication lag, eventual consistency
Rate LimitingPrevent abuseToken bucket vs leaky bucket
Interview tip: Don't just say "I'd use Redis for caching." Say "I'd use Redis with a TTL-based eviction policy, accepting eventual consistency in exchange for sub-millisecond read latency β€” the trade-off is appropriate because feed staleness of a few seconds is acceptable."
Topics: #Architecture #Distributed-Systems #Docker #Docker Compose #Faang #Interview #System-Design
πŸ‘οΈ 5214 views

More from Interview Prep & Database

Chat Chat with Kashii