System design

Design the systems interviewers ask about.

Complete walkthroughs: requirements, scale maths, APIs, architecture diagrams, trade-offs and what breaks first.

60

problems

9

categories

710

sections

01Marketplace & BookingURL ShortenerID range leasing + layered read cacheDesign a link shortener that mints unique 7-character codes and serves over a billion redirects a day, using leased ID ranges, an edge plus Redis cache, and an async click pipeline.1.2B redirects a dayRead-heavy, 150 reads per write02Social & FeedNews Feedhybrid push and pull timelinesDesign a home feed for 320 million daily users that pushes posts into follower timelines, pulls from huge accounts at read time, and ranks a few hundred candidates per request.320M daily users25 feed reads per post written03Storage & DataGoogle Drivecontent-addressed chunks + change journalDesign a file sync service for 900 million accounts that splits files into hashed chunks, uploads only what changed, and keeps every device in step through a per-folder change journal.900M accounts, 3.6 EB stored04CommunicationWhatsAppconnection registry + per-device inboxesDesign an end-to-end encrypted messenger that keeps 220 million phones connected, routes each message to every device of every recipient, and holds it safely until each device confirms.67B messages sent a day220M sockets open at peak05Media & StreamingYouTube / Netflixsegment-parallel transcoding + tiered CDNDesign a video platform that turns 400 hours of uploads a minute into adaptive streams through a segment-parallel encoding pipeline, then serves 60 Tbps from caches inside ISP networks.400 hours uploaded a minuteAbout 1,400 views per upload06Search & DiscoverySearch Autocompleteprecomputed top-K per prefixDesign search suggestions that answer every keystroke in tens of milliseconds by precomputing the top ten completions for each prefix offline and overlaying a fast trending stream.3B searches a day520,000 suggestion calls a second at peak07InfrastructureRate Limitertoken bucket (GCRA) in one atomic callDesign a distributed rate limiter for an API that peaks at 1.2 million requests a second, using a token bucket stored as one timestamp per key, checked atomically in Redis in about a millisecond.1.2M requests a second at peakUnder 2 ms added per request08Search & DiscoveryWeb Crawlerpolite frontier + layered dedupDesign a crawler that refreshes 6 billion pages every four weeks without hammering any one site, using a two-level frontier, host-pinned fetchers and a layered duplicate filter.6B pages per 28-day cycle09Search & DiscoveryYelp / Google Placesgeohash cells + in-memory geo indexDesign a nearby-places service for 60 million listings that answers "good ramen within 2 km, open now" in under 150 ms, using geohash cells, a small in-memory geo index and async rating rollups.60M places, 25M daily usersRead-heavy, about 500 reads per write10Social & FeedAd Click Aggregatorevent-time windows + idempotent sinksDesign a pipeline that counts 4 billion ad clicks a day by ad, country and minute, filters bots, survives replays without double billing, and lets advertisers query fresh totals in seconds.4B clicks a day, 185K per second peakDashboards fresh within 30 seconds11Marketplace & BookingAirbnbdate-range inventory + booking sagaDesign a home-rental marketplace for 4.5 million listings where guests search by place and dates, and the booking path guarantees no two guests ever hold the same night, even under retries and payment failures.4.5M listings, 60M searches a day12Financial & TradingBidding Platformsingle writer per auction + replicated bid logDesign an online auction platform that accepts bids from millions of users, orders every bid on an item exactly once, runs proxy bidding fairly, and pushes the current price to 200,000 live watchers.3M live auctions, 5K bids per second peakPrice updates to watchers under 1 second13InfrastructureCode Deployment Pipelinecontent-addressed artifacts + judged canariesDesign the build and deploy pipeline for 800 services: reproducible builds into signed, content-addressed artifacts, then staged rollouts that compare canaries with a baseline and roll back automatically.3,000 production deploys a dayBad change caught at under 2% of traffic14CommunicationCollaborative Whiteboardper-field CRDT + tiled viewport syncDesign a Miro-style whiteboard where dozens of people edit one infinite canvas at once, using a per-field CRDT, tiled viewport loading, throttled presence and an undo stack that belongs to each user.Boards up to 60K objects40 live editors on one board15InfrastructureCount Unique Active Usersmergeable HyperLogLog sketches per time bucketDesign a service that reports daily, weekly and monthly unique users from billions of events, using HyperLogLog sketches per time bucket that merge into any window with under 1% error.2.4B activity events a dayUnder 1% error, 12 KB per sketch16Financial & TradingCrypto Exchangeper-market matching + reserved balances + tiered custodyDesign a Coinbase-style exchange with an in-memory matching engine per market, balance reservation before orders reach the book, chain watchers for deposits and a hot, warm and cold wallet split.250K orders a second in a spike40 networks to watch17InfrastructureCDNanycast edges + parent tier + tag purgeDesign a global CDN that routes users to nearby sites with anycast, shards cache inside each site, shields origins behind a parent tier and purges content by tag worldwide in about two seconds.30M requests a second at peak180 PoPs, about 14 Tbps out18InfrastructureChatGPTpaged KV cache + continuous batching + cache-aware routingDesign a ChatGPT-style assistant that serves 40M daily users by streaming tokens from GPU replicas, using a paged KV cache, continuous batching, prefix-aware routing and safety checks that run alongside generation.40M daily usersAbout 4M output tokens a second at peak19InfrastructureDistributed Cacheslot-based sharding + async replicas + sampled evictionDesign a Redis-style distributed cache that serves 3M operations a second from RAM, using hash slots for sharding, replicas with automatic failover, sampled eviction and guards against hot keys and stampedes.3M operations a secondReads under 1 ms at p9920InfrastructureDistributed Job Schedulertime-bucketed due index + leased shardsDesign a scheduler that fires 4 million one-off and recurring jobs on time across a sharded fleet, using time-bucketed due indexes, leased shards, fencing tokens and idempotent dispatch.4M active jobs, 30K fires a second at peakFire skew under 2 s21InfrastructureDistributed Lockingconsensus-backed leases + fencing tokensDesign a shared lock service for hundreds of microservices: Raft-replicated lock state, session leases, wait queues, and fencing tokens that keep a paused client from corrupting data.18K lock operations a secondAcquire p99 under 15 ms22Storage & DataDistributed Logging Frameworklabel index + compressed chunks, scan in parallelDesign a log platform that ingests a million lines a second from 60,000 pods, keeps them searchable for a year, and serves live tail and alerts, using Kafka, label indexes, bloom-filtered chunks and tiered storage.360K lines a second, 1.1M at peakSearchable within 10 s of emit23InfrastructureDistributed Priority Queueper-shard priority lanes + head summaries for near-global orderDesign a priority queue that spreads 1.2 billion messages a day across many shards yet still hands consumers the most urgent work first, with lanes per priority, lease-based delivery, delays and starvation control.1.2B messages a dayUrgent work dequeued under 50 ms24Marketplace & BookingDoorDash / Uber Eatsbatched dispatch against predicted food-ready timeDesign a food delivery marketplace for 4.5 million orders a day: an order saga across three apps, an H3 courier index fed by 44,000 GPS pings a second, and batched dispatch timed to food-ready.4.5M orders a day, 900 a second at dinner peakCourier assigned in under 30 s25Storage & DataDropbox Synccontent-addressed blocks + journal cursors + three-tree reconcileDesign a file sync service for 400 million users: hashed 4 MB blocks with cross-account dedup, a per-namespace change journal, a three-tree sync engine on every device, and conflicted copies instead of silent overwrites.400M users, 70M active devices a dayChanges on other devices in under 10 s26Marketplace & BookingE-Commerce Platformconditional stock holds + checkout sagaDesign a marketplace storefront that serves 540 million browse requests a day from caches and a search index while checkout holds stock, takes payment and never sells a unit twice.540M browse requests a day27Marketplace & BookingFlash Salepaced waiting room + atomic unit tokensDesign a limited drop where 400,000 people chase 2,500 pairs of sneakers: a shuffled waiting room, a CDN-cached progress beacon, atomic unit tokens and one-tap payment.400K shoppers for 2,500 units28Financial & TradingReal-time Fraud Detectionstreaming features + rules and model + delayed labelsDesign a payment risk engine that scores 24,000 payments a second in under 80 ms, mixing analyst rules, a tree model and fresh streaming features, then learns from labels that arrive weeks later.24K decisions a second at peakp99 under 80 ms29CommunicationGmaildurable SMTP intake + per-user mailbox and indexDesign a webmail service for 1.2 billion mailboxes: an SMTP edge that rejects most junk, durable intake, label-based mailboxes sharded by user, a search index per user and fast sync.1.2B mailboxes30Financial & TradingGoogle Adsquality-weighted auction + budget pacing + exact click billingDesign a search ads platform that runs 160,000 auctions a second inside 60 ms, ranks by bid times predicted clicks, paces daily budgets with spend leases and bills each valid click once.160K auctions a second at peak60 ms ad decision31CommunicationGoogle Calendarstore rules, expand per window + busy-interval cacheDesign a calendar for 900 million accounts: repeating events stored as rules and expanded per view, zone-aware times, attendee fan-out, a busy-interval cache and reminders that survive the top of the hour.900M accounts32Storage & DataGoogle Docs / Live Collaborative Editorone sequencer per document + operational transformDesign a live document editor where many people type into one file at once: a per-document sequencer, operational transform, an append-only op log and snapshots that keep every replica identical.1.3M edit batches a second at peakSub-200 ms edit fan-out33Search & DiscoveryGoogle Mapsprecomputed road hierarchy + live traffic weightsDesign a maps platform that draws the world from cached vector tiles, finds driving routes in milliseconds over a billion road edges, and folds millions of live GPS pings into traffic-aware ETAs.3.7M GPS pings a secondRoute answer in under 300 ms34Search & DiscoveryGoogle Newsincremental story clustering + edition-then-personal rankingDesign a news aggregator that pulls articles from 60,000 publishers, groups them into stories as they arrive, ranks stories by freshness and source quality, and serves a personal front page in milliseconds.250K new articles a day35K feed loads a second at peak35Social & FeedInstagramresumable media pipeline + hybrid feed fan-outDesign a photo and short video app: resumable direct-to-storage uploads, an async pipeline that builds every size and bitrate, a follow graph, and a ranked home feed built by hybrid fan-out.70M posts a day250K feed loads a second at peak36Storage & DataKey-Value Storehash partitions + per-partition Raft + LSM storageDesign a distributed key-value database that splits data into hash partitions, replicates each one with Raft, stores it in an LSM engine, and keeps single-digit millisecond latency while it grows.4M operations a second at peak60 TB of live data37Social & FeedTop-K Leaderboardrank-aware sorted sets fed from a durable score logDesign a game leaderboard that ranks 80 million players in real time: a durable score log, Redis sorted sets for rank queries, fair tie-breaking, scoped and friends boards, and a plan for outgrowing one shard.80M players on the all-time board45K score updates a second at peak38InfrastructureLeetCodeisolated runners fed by a priority queueDesign an online judge that compiles and runs untrusted code in 20 languages, returns a verdict within seconds, and keeps weekly contests fair when 60,000 people press submit at once.6M submissions a dayContest verdict p95 under 8 s39Media & StreamingLive Streaming Platformtranscode ladder + CDN segment fan-outDesign a Twitch-style live platform that takes 90,000 simultaneous broadcasts, transcodes each into a quality ladder, and pushes it to 9 million viewers in under 4 seconds, with chat alongside.9M concurrent viewers at peakGlass-to-glass under 4 s40InfrastructureMetrics & Monitoringcompressed time series blocks + label indexDesign a metrics platform that ingests 40 million samples a second from 400,000 hosts, stores them compactly for a year, answers dashboard queries in under a second, and fires alerts within a minute.40M samples per secondAlert within 60 s41Social & FeedLinkedIn MutualConnection Searchsharded adjacency lists + adaptive set intersectionDesign the service behind "14 mutual connections" on a professional network of 900 million members, answering single and batched intersection queries in milliseconds with sorted adjacency lists and filters.900M members, 45B edges25 results per search page42CommunicationNotification Systemper-channel queues + idempotent delivery workersDesign a shared notification platform that sends 1.5 billion push, email, SMS and in-app messages a day, respects every user preference and quiet hour, and never sends the same alert twice.1.5B notifications a dayOTP push under 5 s43Financial & TradingPayment Gatewayidempotency keys + payment state machine + ledgerDesign a Stripe-style gateway that takes 25 million card payments a day from merchants, charges each exactly once despite retries and timeouts, keeps a double-entry ledger and reconciles with banks.25M payments a day44GamingDesign PUBGauthoritative tick loop with prediction and rewindDesign a 100-player battle royale: warm match servers ticking at 30 Hz, client prediction, lag compensation, relevance filtering and a fleet that runs 26,000 matches at once.26,000 concurrent matches at peak45Social & FeedRecommendation Algorithmretrieval funnel then precise rankingDesign a "picked for you" engine that narrows 40 million items to 30 in under 150 ms, using parallel retrievers, an ANN index, a multi-task ranker and streaming session features.50,000 requests a second at peakLatency budget 150 ms46Social & FeedReddit-Style Commentsbudgeted level-by-level tree fetchDesign threaded comments that return a sorted, pruned slice of a 50,000-comment tree in under 200 ms, using per-level budgeted fetches, stored sort scores and batched vote aggregation.25,000 thread views a second at peak47Social & FeedRedditprecomputed hot lists plus batched vote deltasDesign Reddit around its three hard parts: hot ranking kept in precomputed sorted sets, comment trees fetched within a budget, and a vote pipeline that batches deltas instead of locking rows.36,000 page loads a second at peak48CommunicationReminder Alertwall-clock rules with derived UTC bucketsDesign a reminder service that fires 140 million alerts a day at the right local time, using minute-bucketed schedules, leased scanners, careful time-zone handling and deduplicated delivery.47,000 fires a second in the busiest minute49Storage & DataAmazon S3replicate then erasure-code, with a consistent key indexDesign an object store holding 600 PB in one region, with eleven nines of durability from erasure coding, read-after-write consistency in a Raft-backed key index, and load-based partition splits.40 trillion objects in one region50Search & DiscoverySearch Engineinverted index + ranking cascadeDesign a web search engine over 20 billion pages that answers 80,000 queries a second in under 300 ms, using a tiered inverted index, an aggregator tree and a ranking cascade.80K queries a second at peak20B pages, tiered by quality51Marketplace & BookingShopping Cartversioned cart document + checkout quoteDesign a shopping cart for 25 million daily shoppers that survives concurrent edits, merges guest carts at sign-in, reprices on every view and hands checkout a pinned quote.130K cart reads a second on sale days52CommunicationSlack / Discordchannel owners + gateway fan-outDesign a team and community chat system for 25 million live connections and 2.5 billion daily messages, using channel owners, sequence numbers, gateway fan-out and lazy delivery.25M concurrent connectionsChannels up to 700K members53Financial & TradingHigh-Throughput Stock Exchangedeterministic engine on a sequenced logDesign a stock exchange that matches 1.7 million messages a second with microsecond latency, using deterministic single-threaded engines, a replicated input log and multicast market data.1.7M order messages a second at the openMedian ack under 20 microseconds54Financial & TradingStock Trading Platformevent-sourced orders + derived buying powerDesign a retail brokerage that places 16,000 orders a second on a frantic open, keeps buying power exact through partial fills, and streams prices to 1.5 million phones at once.1.5M sessions at the market openT+1 settlement and nightly reconciliation55Marketplace & BookingTicketmaster / StubHubatomic seat holds + virtual waiting roomDesign a ticketing platform that sells 60,000 stadium seats to 2.5 million fans in about ten minutes, using a virtual waiting room, atomic conditional holds and lazy hold expiry.2.5M fans for 60K seats56Social & FeedTwitter Trendingwindowed sketches + surprise scoringDesign a trends service that turns 720 million posts a day into ranked, per-region trend lists every minute, using windowed sketches, surprise scoring against history and author-level spam defences.720M posts a dayAbout 850 geo and language scopes57Marketplace & BookingUber / Ride Sharinghexagon index + atomic driver claimDesign a ride-hailing platform that tracks millions of moving drivers, matches each request to one car in seconds, streams the trip live and prices surges, using hexagon indexing and city-scoped cells.18M trips a day500K location writes a second at peak58InfrastructureUnique ID Generatortime-ordered 64-bit IDs from leased worker slotsDesign an ID generator that lets thousands of processes mint unique, time-sortable 64-bit keys locally, using a custom bit layout, leased worker slots and careful handling of clocks that move backwards.1.4M IDs a second at peak41 / 12 / 10 bit split59CommunicationVideo Conferencingedge SFUs with simulcast and per-viewer layer choiceDesign a video meeting platform for 25 million concurrent participants, using edge selective forwarding units, simulcast layers, a bandwidth ladder per viewer and cascaded servers for global meetings.25M people in calls at peakMouth-to-ear under 250 ms60Social & FeedYouTube Likes Counterlike edges as truth, counts as batched deltasDesign a like counter for a video platform that records each viewer's reaction exactly once and keeps public counts fresh within seconds, using durable like edges, keyed streams and batched count deltas.280K reactions a second at peak1.2M count reads a second