System Design Fundamentals

Classic System Design Problems

5 min read

These five problems appear repeatedly in interviews. Knowing their solutions builds the muscle memory to tackle any design problem.

1. URL Shortener (Like bit.ly)

Requirements: Generate short URLs, redirect to original, handle high read traffic.

Key Design Decisions:

ComponentChoiceWhy
ID GenerationBase62 encoding (a-z, A-Z, 0-9)62^7 = 3.5 trillion unique codes
DatabaseNoSQL (DynamoDB)Simple key-value lookups, high throughput
CacheRedis80/20 rule: 20% of URLs get 80% of traffic
ArchitectureRead-heavy100:1 read-to-write ratio

Flow:

Create: Client → API → Generate ID → Store in DB → Return short URL
Redirect: Client → CDN/Cache → DB (on miss) → 301 Redirect

2. Rate Limiter

Requirements: Limit API requests per user/IP to prevent abuse.

Algorithms:

AlgorithmHow It WorksProsCons
Token BucketTokens added at fixed rate, each request consumes a tokenAllows bursts, smoothNeeds tuning
Sliding Window LogTrack timestamps of requests in a windowAccurateMemory-heavy
Sliding Window CounterCombine fixed window counts with sliding calculationLow memory, accurate enoughApproximate
Fixed WindowCount requests in fixed time windowsSimpleBoundary burst problem

Where to place it: API Gateway or as middleware. Use Redis for distributed rate limiting across multiple servers.

3. Chat System (Like WhatsApp/Slack)

Requirements: 1:1 messaging, group chats, online presence, message history.

Key Components:

Clients ↔ WebSocket Servers ↔ Message Queue (Kafka)
                              Message Store
                              (Cassandra)
DecisionChoiceWhy
ProtocolWebSocketBidirectional, real-time, persistent connection
Message storageCassandraWrite-heavy, time-series data, partition by chat_id
Message deliveryPush (WebSocket) + Pull (on reconnect)Reliable delivery
Online presenceRedis with TTLFast lookups, auto-expire
Group messagesFan-out on write (small groups) or fan-out on read (large groups)Trade-off: write amplification vs read latency

4. News Feed (Like Twitter/Facebook)

Requirements: Users post content, followers see posts in chronological/ranked order.

Two approaches:

ApproachHowProsCons
Fan-out on writeWhen user posts, push to all followers' feedsFast readsSlow writes for celebrities (millions of followers)
Fan-out on readWhen user opens feed, pull from followed usersFast writesSlow reads, needs merging
HybridFan-out on write for normal users, on read for celebritiesBalancedMore complex

Architecture:

Post Service → Fan-out Service → Feed Cache (Redis)
                                Feed Service → Client

5. Notification Service

Requirements: Send push/email/SMS notifications reliably at scale.

Design:

Trigger Event → Notification Service → Priority Queue
                                    ┌───────┼───────┐
                                    ↓       ↓       ↓
                                  Push    Email    SMS
                                (APNs/   (SES)  (Twilio)
                                 FCM)

Key considerations:

  • Deduplication: Idempotency keys to prevent duplicate notifications
  • Rate limiting: Don't overwhelm users
  • Priority: Urgent notifications bypass queue
  • Retry: Exponential backoff with dead-letter queue for failures
  • Templates: Centralized template management for consistency

System Design Answer Template

When you walk through any design, follow this structure:

  1. "The system needs to..." (requirements)
  2. "At this scale, that means..." (estimation)
  3. "The high-level architecture is..." (diagram)
  4. "For [component], I'd choose [X] because..." (justified decisions)
  5. "The trade-off here is..." (shows maturity)
  6. "To handle [edge case], we'd..." (demonstrates depth)

Next, let's cover scaling patterns and reliability -- the topics that differentiate senior candidates. :::

Quiz

Module 4 Quiz: System Design Fundamentals

Take Quiz
FREE WEEKLY NEWSLETTER

Stay on the Nerd Track

One email per week — courses, deep dives, tools, and AI experiments.

No spam. Unsubscribe anytime.