← Back to Index

12. Case Studies

Apply the 4-step blueprint to real-world systems. Each study includes requirements, scale estimates, architecture, and key trade-offs.

1. URL Shortener (e.g., TinyURL, bit.ly)

Requirements: Generate short aliases for long URLs; redirect to original URL on visit; track click count; optional expiration.

Scale: 100M URLs/month, 1B redirects/month, read-heavy (10:1 read-to-write).

Key Design Decisions:

# API Design
POST /shorten { "url": "https://example.com/very-long-url" }
Response: { "short_url": "https://short.ly/Ab3X9zQ" }

GET /Ab3X9zQ → HTTP 301 redirect to original URL

2. Ticketing System (e.g., BookMyShow, Ticketmaster)

Requirements: Browse events, select seats, reserve and pay within a time window, handle concurrent booking (no double booking).

Challenges: Race conditions on seat selection, payment failures after reservation, high traffic on popular events.

Key Design Decisions:

3. News Feed (e.g., Facebook, Twitter, LinkedIn)

Requirements: Users see posts from followed accounts, ordered by recency/relevance, support infinite scroll, low latency (~500ms).

Approaches:

# Hybrid feed approach
When user A posts:
  For followers with timeline in cache:
    Push post to each follower's timeline list (Redis sorted set, score=timestamp)
  For inactive followers / celebrities:
    Store post in A's timeline; followers pull on login

4. Notification System

Requirements: Send push notifications, emails, and SMS to millions of users. Support multiple channels, delivery tracking, rate limiting.

Architecture:

5. Chat Application (e.g., WhatsApp, Messenger)

Requirements: Real-time messaging, group chats, message delivery status (sent/delivered/read), offline messages, media sharing.

Key Design Decisions:

6. Auction Platform (e.g., eBay)

Requirements: List items, place bids, auto-bidding, auction countdown, outbid notifications.

Challenges: Last-second bidding (sniping), concurrent bids on the same item, real-time countdown accuracy.

Key Decisions:

7. Rental Platform (e.g., Airbnb)

Requirements: List properties, search with filters (dates, location, price, amenities), booking calendar, reviews, payments.

Key Challenges: Calendar availability (complex date overlap queries), search with geo-indexing, review moderation.

8. Cloud Storage (e.g., Google Drive, Dropbox)

Requirements: Upload/download files, sync across devices, file versioning, sharing with permissions, conflict resolution.

Architecture:

# File sync flow
User saves file → Client diffs chunks
Upload changed chunks to object storage
Update metadata DB: "file_id=42, version=5, chunk_list=[...]"
Notify other devices: "File X updated to v5"
Other devices download changed chunks and merge

9. Video Sharing (e.g., YouTube)

Requirements: Upload videos (up to 4K, multi-GB), transcoding to multiple resolutions, streaming with adaptive bitrate, search, recommendations, comments.

Key Components:

10. Search Engine (e.g., Google, Bing)

Requirements: Crawl billions of pages, index content, return relevant results in <500ms, handle typos, support advanced queries (site:, filetype:).

Architecture:

11. E-Commerce Platform (e.g., Amazon)

Requirements: Product catalog, search, cart, checkout, payments, order tracking, inventory management, recommendations.

Key Services:

12. Taxi Booking (e.g., Uber, Lyft)

Requirements: Real-time driver location updates, rider requests nearby drivers, fare calculation, trip tracking, ETA prediction.

Challenges: Updating 10M driver locations every 3 seconds, finding nearest driver in <100ms, surge pricing.

Key Decisions:

13. Collaborative Editor (e.g., Google Docs, Notion)

Requirements: Multiple users editing the same document simultaneously, real-time cursor visibility, conflict resolution, version history.

Key Approaches:

# CRDT character example (simplified)
Char { id: "user1:42", value: "a", position: [3, "user1:40"] }
Insert operation: insert character with ID between two existing positions
Positions form a linked list; concurrent inserts converge naturally
Exercise: Pick two case studies from this chapter that interest you most. For each, write the complete 4-step design (Problem → Scale → HLD → Infra Decisions → Final Design). Include trade-off analysis. Aim for 2—3 handwritten pages per study.