Overview– Online shopping platform that allows users to purchase mobiles, laptops, cameras, and books. Watches, apparel, shoes, etc. Functional Requirements– User should be able to search and find products based on product titles or names. User should be able to view the details of the product (Description, image, available quantity, review) User should be able to select the quantity and move the item to cart. User should be able to make the payment and do the checkout. User should be able to check the status of the order Manage purchase of items having limited stock. Non-Functional Requirements— Scale: 10M MAU and 10 orders/sec CAP Theorem: Highly available with respect to searching and viewing the items, and highly consistent with respect to placing the order and payment. Core Entities— User Product Cart Order Checkout API– // Search Product GET: /products/search?q={seachTerm} → List <ProductId> list : Pagination // Product Detail GET: /products/{productId}→ return the product details (json) // Insert Data POST: /cart {body: all product Id} → return cartId // checkout and payment POST: /checkout {body: all product Id with wty and price} → orderId POST: /payment {body: orderId and payment details} → confirmation // order Status GET: /status/{orderId} High-Level Design–
Overview– A web crawler is a program that automatically traverses the web by downloading web pages and following links from one page to another. It is used to index the web for search engines, collect data for research, or monitor websites for changes. Problem Definition– Design a web crawler to extract text data from the web and store it to train an LLM. Your crawler can run for only 5 days. Functional Requirements– Crawl the full web starting from seed urls Extract text data and store Scale– 10B web pages 2MB per page avg. 5 days to scrape Unlimited resources (withing reason) Non-Functional Requirements– Fault tolerant Politeness Scale to 10B pages Efficiently crawl in under 5 days Core Entities— Text Data URL metadata Domain metadata Interface– input – set of seed urls Output – text data Data Flow– Take seed urls from a frontier and the IP from DNS Fetch HTML Extract text from HTML Store that text in database Extract the urls in the text and add to our frontier Repeat steps 1-5 until all urls have been crawled High-Level Design– Efficiency– Don’t crawl a URL that has already been added. Don’t parse a webpage with duplicate content that has already been parsed.
Overview– YouTube is a video-sharing platform that allows users to upload, view, and interact with video content. As of this video, it is the second most visited website in the world. Functional Requirements– Users should be able to upload videos. Users should be able to watch/stream videos. Scale ~1M uploads/day 100M DAU Max video size of 256GB Non-Functional Requirements– Availability >> Consistency for video uploads Support uploading/streaming for large videos (256GB) Low latency streaming (<500 ms) is true in low bandwidth Scalability to scale to 1M uploads per day and 100M views Core Entities— User Video Video Metadata API //upload a video POST /videos { videoMetadata } //watch a video GET /videos/:videoId → video & videoMetadata High-Level Design–
Overview– WhatsApp is a messaging service that allows users to send and receive encrypted messages and calls from their phones and computers. WhatsApp was famously originally built on Erlang (no longer!) and renowned for handling high scale with limited engineering and infrastructure outlay. Requirements– Start group chat send/receive messages send/receive media Access messages after I've been offline. Non-Functional Requirements— Delivered with low latency < 500ms Guarantee delivery messages Billions of users, high throughput Messages not stored unnecessarily. Fault-tolerant Core Entities— Messages Users Chat Client API- Commands Sent Commands Received createChat - newMessage sendMessage - chatUpdate createAttachment modifyParticipants High-Level Design–
Overview-- The system allows users to create, edit, delete, like, retweet, and reply to tweets. Users can follow other users and see their tweets on a personalized Timeline (Home Feed). It also supports tweet search and user profile management. Functional Requirements-- User should be able to create, edit, and delete tweets. Users should be able to like, retweet, and reply to tweets. Users should be able to search for tweets. Users should be able to view tweets from users they follow on their homepage. Users should be able to create an account and log in. Users should be able to follow other users. Non-Functional Requirements— High Throughput: Capable of handling thousands of tweets, replies, and timeline requests per second Low Latency: Timeline and tweet loading should be fast (target < 200ms) Scalability: Horizontal scaling to support millions of users and growing traffic High Availability: 99.9%+ uptime (system should remain available even if some services fail) Fault Tolerance: Graceful handling of service or database failures Eventual Consistency: Acceptable for timeline feeds (latest tweets may have slight delay) Data Durability: No loss of tweets, replies, or user data Rate Limiting: Prevent abuse and control traffic from individual users Security: Strong authentication, authorization, SSL/TLS, and data privacy Performance: Efficient read-heavy (timeline) and write operations High-Level Design—
Overview– Bit.ly is a URL shortening service that converts long URLs into shorter, manageable links. Ie. www.mulongurl.com/is/annoying -> www.bit.ly/Gs23 Functional Requirements– Users can create a short url from a long url. Optionally support custom alias. Optionally support an expiration time. Users can redirected to the original url from the short url. Non-Functional Requirements— Low latency on redirects (~200ms) Scale to support 100M DAU and 1B urls Ensure uniqueness of short code High Availability, eventual consistency for url shortening. Core Entities— Original url Short url User API– POST /urls → shortUrl { originalUrl, alias?, expirationTime? } GET {shortUrl} → Redirect to originalUrl High-Level Design–
Overview–
Dropbox is a cloud-based file storage service that allows users to store and share files. It provides a secure and reliable way to store and access files from anywhere on device.
Functional Requirements– Upload a file. Download a file. Automatically sync files across devices. Out of scope– Roll own blob storage. Non-Functional Requirements– Availability >> consistency. Low latency upload and downloads. (as low as possible) Support large files as 50gb Reusable uploads High data integrity. (sync accuracy) Core Entities– File (raw bytes) File Metadata Users API– POST /files -> Presinged Url body: File & FileMetadata PUT {presigned url} Body file/chunk PATCH /files -> 200 GET /files/:fileId -> File & FileMetadata GET /changes?since={timestamp} -> fileIds[] High Level Design–
Overview– Uber is a ride-sharing platform that connects passengers with drivers who offer transportation services in personal vehicles. It allows users to book rides on demand from their smartphones, matching them with a nearby driver who will take them from their location to their desired destination. Functional Requirements– Users should be able to input a start location and a destination and get an estimated fare. Users should be able to request a ride based on an estimate. Drivers should be accept/deny a request and navigate to pickup/drop-off Out of scope— Multiple car types Rating for drivers and riders Schedule a ride in advance Non-Functional Requirements– Low latency matching < 1 min match or failure Consistency of math. Ride to driver is 1:1 Highly available outside the matching. Handle high throughput and surges for peak hours or special events. 100s of thousands of requests within a given region. Out of scope— Resilience and handling system failures Monitoring logging, alerting, etc. CI/CD pipeline Core Entities— Ride Driver Rider Location API– POST /ride/fare-estimate -> Partial<Ride> { Source, destination } PATCH /ride/request -> 200 { rideId } POST /location/update { lat, long } PATCH /ride/driver/accept { rideId, true/false } PATCH /ride/driver/update -> lat/long | null { rideId, status: “pickup | droppedoff” } High Level Design --
Overview -
Ticketmaster is an online platform that allows users to purchase tickets for concerts, sports events, theater and other live entertainment. Has ~100M DAU
Functional Requirements-
- User Should be able to book tickets
- View an event
- Search for events
Non-Functional Requirements-
- Strong consistency for booking tickets and high availability for search and viewing events / consistency >> availability (no double booking)
- read >> write
- scalability to handle surges from popular events
Out of Scope:
- GDPR compliance
- fault tolerance
- etc.
Core Entities- - Event - Venue - Performer - Ticket API- GET /event/:eventId -> Event and venue and performer and ticket[] GET /search?term={term}&location={lcoation}&type={type}&date={date} -> Partial<Event>[] POST /booking/reserve header: JWT | SessionToken body{ ticketId } PUT /booking/confirm header: JWT | SessionToken body{ ticketId paymentEtails(stripe) } High Level Design-
Overview- A scalable, eventually consistent social feed service supporting post creation, following, and chronological timeline viewing for up to 2 billion users. Functional Requirements– Users should be able to create posts. Users should be able to follow other users. Users should be able to view a feed of posts (from other people they follow, in chronological order). Users should be able to page/scroll through their feed. Non-Functional Requirements– The system should be highly available. (It should be eventual consistency, and we can tolerate a ½-minute delay). (Availability). Posting and viewing feed should be fast within < 500 ms. (Latency). The system should be able to scale to 2B users. (Scaleability). Users should be able to follow an unlimited number of people. (Scaleability). Core Entities— User. Follow. Post. API: POST/posts{"content":{""}} 201 {“postId”://} PUT/users/{id}/followers{“userId”:”userId”} 200 GET/feed?pageSize={size}&cursor={timestamp} Capacity Estimation– Assuming 2 billion total users and 10% DAU (200 million): Posts: 3–5 per DAU/day → 600M–1B posts/day (~7–12K write QPS peak) Feed views: 150–250 sessions/DAU/day → 30–50B reads/day (~350–580K read QPS peak) Read:write ratio: 40–80:1 Peak QPS: ~500–800K (mostly reads), with potential 3–5x spikes Latency goal: <500 ms p99 for posts and feed loads Storage (text posts, 1-year retention): ~150–400 TB (200–400 bytes/post + ×3 replication) High availability with eventual consistency (tolerate up to ~30s delay for new posts in feeds). Cache Capacity Estimation– Using push-on-write model with per-user timelines in Redis sorted sets (post IDs + timestamps): Stored per user: recent 500–800 posts (covers initial 5–10 scroll pages) Size/entry: ~40–60 bytes Per-user footprint: ~25–50 KB Total for 200M DAU: ~5–10 TB raw With ×3 replication, overhead, headroom: 15–30 TB RAM across Redis cluster Optimizations: Warm cache only for active users (last 30 days) LRU eviction + TTL for stale data Cache miss fallback: on-the-fly merge from Post DB + Follow indexes Separate pull model for celebrity/high-follower accounts to prevent fan-out overload. High Level Design (HLD)— Fan-out on Write (Push Model): Enables fast reads (<500 ms) via precomputed caches but risks write overload for celebrity users (e.g., 1M+ followers → massive queue backlog). Mitigated by hybrid approach (push for normal users, pull for high-follower accounts). Eventual Consistency: Tolerates ~30s delay, which simplifies scaling and availability but may cause brief stale feeds (acceptable per NFR). Hot Keys/Shards: Popular users or viral posts can overload specific DB shards or cache nodes. Solution: Sharding by user ID, consistent hashing, and separate handling for celebrities. Read-Heavy Workload: ~40–80:1 read:write ratio means heavy caching and horizontal scaling of Feed Service + Redis cluster. Storage Bottleneck: Text posts scale to hundreds of TB/year; media (images/videos) would require CDN + object storage (e.g., S3-like) and inflate costs significantly. Personalized Ranking: Add ML-based layer (e.g., engagement prediction) to reorder chronological feed → “For You” style. Real-time Updates: Integrate WebSocket / Pub-Sub (Kafka/Redis PubSub) for live push notifications instead of polling. Media Support: Store images/videos in CDN, reference URLs in Post entity. Search & Discovery: Add full-text search (Elasticsearch) for posts/hashtags. Security/Privacy: Rate limiting, abuse detection, private accounts, block/mute features. Posts: Cassandra / ScyllaDB (wide-column, high write throughput, time-series friendly) or MySQL sharded by post ID. Follows: Graph DB (Neo4j) or relational table with indexes on follower/followee. Feed Cache: Redis (sorted sets for timelines) clustered and sharded. Queue: Kafka or RabbitMQ for async fan-out to handle spikes.Trade-offs & Bottlenecks
Future Improvements / Out of Scope
Database Choices (Suggested)