Career OS

Week 11 — System Design Interview Practice

Before the practice problems

The method behind this week is How To Learn System Design; the case study shows a full design narrated. For the DSA weekend, the recognition drill is Which Pattern? The Decision Engine.

The Framework (Use This for Every Question)

1. CLARIFY (2-3 min) — Ask questions. Don't assume.
2. ESTIMATE (2 min) — Back-of-envelope: users, QPS, storage.
3. HIGH-LEVEL DESIGN (5-7 min) — Draw boxes and arrows.
4. DEEP DIVE (10-15 min) — Interviewer picks a component. Go deep.
5. TRADE-OFFS (3-5 min) — What would you change at 10x scale?

Practice These 4 Problems This Week

Problem 1: URL Shortener (Monday)

Clarify: 100M URLs/month, 10:1 read:write ratio

Key decisions:

  • ID generation: Base62 encoding of auto-increment ID (not hash — collisions)
  • Database: SQL for consistency, read replicas for the 10:1 read ratio
  • Cache: Redis for hot URLs (80% of traffic hits 20% of URLs)
  • Redirect: 301 (permanent, browser caches) vs 302 (temporary, analytics-friendly)
Client → Load Balancer → API Server → Redis Cache (hit?) → PostgreSQL
                                           ↓ (miss)
                                       PostgreSQL → write to Redis → return

Fintech connection: URL shorteners use the same patterns as payment link generators (Razorpay payment links, Stripe checkout links).

Problem 2: Chat System (Tuesday-Wednesday)

Clarify: 1M daily users, group chats up to 100 members, message history

Key decisions:

  • Real-time: WebSocket connections (not polling)
  • Message storage: Cassandra or DynamoDB (write-heavy, partition by chat_id)
  • Delivery: At-least-once delivery + client-side dedup with message IDs
  • Presence: Redis pub/sub for online status
  • Push notifications: Message queue → notification service
Client ←WebSocket→ Chat Server → Message Queue → Delivery Service
                         ↓                            ↓
                    Message DB                   Push Notification

Problem 3: Rate Limiter (Thursday)

Clarify: 1000 requests/minute per user, distributed across multiple servers

Key decisions:

  • Algorithm: Sliding window counter (balance between accuracy and memory) — the pattern from DSA 04, applied to time windows
  • Storage: Redis (fast, shared across servers)
  • Key design: rate_limit:{user_id}:{minute_window}
-- Redis Lua script (atomic operation)
local current = redis.call('INCR', KEYS[1])
if current == 1 then
    redis.call('EXPIRE', KEYS[1], 60)
end
if current > 1000 then
    return 0  -- rejected
end
return 1  -- allowed

Fintech connection: Every payment API uses rate limiting. Stripe rate limits to 100 requests/second. Understanding this deeply is directly relevant.

Problem 4: Notification System (Friday)

Clarify: Push, SMS, email. 10M notifications/day. Priority levels.

Key decisions:

  • Architecture: Event-driven with message queue
  • Priority queue: High-priority (payment confirmations) before low-priority (marketing) — a heap, the structure from DSA 09
  • Template engine: Don’t hardcode messages — templates with variables
  • Delivery tracking: Track sent, delivered, opened, failed
  • Retry strategy: Exponential backoff for failures
Event Source → Message Queue (Kafka) → Priority Router

                              ┌── Push Service (Firebase)
                              ├── SMS Service (Twilio)
                              └── Email Service (SES)

                                   Delivery Tracker DB

How to Practice

  1. Set a timer for 35 minutes (real interview time)
  2. Draw on paper or whiteboard — not in code editor
  3. Talk out loud — interviews are conversations
  4. Record yourself — listen back, find where you hesitate

Weekend: Mock Interview + DSA

Resources

WhatWhereTime
System Design Primer — all problemsgithub.com/donnemartin/system-design-primerOngoing
ByteByteGo — visual explanationsYouTube (10-15 min per topic)1 video/day
Designing Data-Intensive ApplicationsMartin Kleppmann (THE book for depth)Read Ch 1-3 minimum
Grokking System DesignFree summaries available onlineAlternative to Primer