Design a URL Shortener
A URL shortener looks trivial. Accept a long URL, return a short one, redirect anyone who clicks it. You could build a working prototype in an afternoon with a hash map and a web server.
🎉 Launch Sale: Get 30% off annual plans with code LAUNCH30
🎉 Launch Sale: Get 30% off annual plans
LAUNCH30Use code at checkout for exclusive savings on yearly membership
Real content with database schemas, API designs, capacity calculations, and the exact tradeoffs interviewers expect you to discuss.
Catalog snapshot
Articles
63
Topics
27
Reading
2300m
A URL shortener looks trivial. Accept a long URL, return a short one, redirect anyone who clicks it. You could build a working prototype in an afternoon with a hash map and a web server.
A user with 50 followers posts a tweet. Your system writes 50 timeline entries — one into each follower's precomputed feed. Simple, fast, and the read path is a single sorted-set lookup. Now a cele...
Sending a message feels instant. You type "hello," tap send, and it appears on your friend's screen. Behind that simplicity is one of the hardest real-time systems to build correctly.
Every system has a breaking point. A database that handles 10,000 queries per second collapses at 50,000. An API server that serves 200 ms responses at normal load starts timing out at 3× traffic. ...
A rider opens the app, taps "Request Ride," and expects a driver to appear on their screen almost instantly. Behind that expectation is a system that must ingest 500,000 GPS updates per second from...
You receive dozens of notifications every day — a shipping update, a login verification code, a friend's message, a price drop alert. Each one feels trivial. But behind that "Your order has shipped...
Every time you see an ad on a website, an impression event fires. Every time you click one, a click event fires. These events look trivial — tiny JSON payloads, maybe 320 bytes each. But multiply t...
Beyoncé drops an album announcement post at 9:00 AM Eastern. Within 300 milliseconds, Facebook's feed infrastructure must decide which of her 95 million followers see it in their home feed, in what...
A user clicks play on a video. In the next 2 seconds, your system must: - Authenticate and authorize the request - Determine which video quality the user's network can handle - Fetch the initial vi...
A 16-year-old in Jakarta uploads a dance video at 11:47 PM local time. She has 47 followers. Within 6 hours, that video has 12 million views, 800,000 likes, and has spawned 3,400 duets. The recomme...
It is 2:47 PM. Two engineers are editing the same design document. Alice inserts a paragraph at position 420: "We should use Redis for caching." At the exact same moment — literally the same millis...
A web crawler seems straightforward. Fetch a page, extract links, add them to a queue, repeat. You could build one in an afternoon with Python and BeautifulSoup.
It is 11:47 PM. You have been working on a critical presentation for three hours. Your laptop is offline — airplane mode on a flight. Meanwhile, your colleague opens the same file on their desktop ...
Autocomplete looks trivial. User types a few characters, system returns suggestions. You could build it with a database query and a `LIKE 'prefix%'` clause in an afternoon.
A cache looks simple. Store frequently accessed data in memory. Return it fast. Evict when full. You could build a working prototype with a hash map and a TTL thread in an afternoon.
Booking a ticket looks trivial. User selects a seat, pays, gets a confirmation. You could prototype it in a weekend with a form, a database, and a payment API.
A job scheduler looks like a simple queue with a clock. Jobs go in, the scheduler waits until the right time, jobs come out. You could build a working prototype with cron and a Redis list in an aft...
An API gateway looks like a simple reverse proxy. Route requests to backends. Add some authentication. Maybe rate limit. You could configure nginx in an afternoon.
A payment system looks like a simple CRUD application. Create a payment, charge a card, record the result. You could build a working prototype with Stripe's API in a few hours.
It is 7:42 PM. A music video from a relatively unknown artist just dropped. In the first 90 minutes, it accumulates 1.8 million views, 340,000 likes, and 89,000 shares. The comment section is explo...
Taylor Swift drops a surprise album at midnight Eastern time. Within 60 seconds, 4.7 million users hit play simultaneously across 78 countries. The CDN must serve 2.3 petabytes in the first hour wh...
Beyoncé goes live to announce her world tour. Within 8 seconds, 2.3 million viewers are connected. Comments start flooding in at 47,000 per second — hearts, questions, excited reactions in every la...
The CEO opens Slack at 8:47 AM and types in #announcements: "@channel We're acquiring TechCorp. More details at the all-hands in 30 minutes." She presses Enter. Within 2 seconds, 47,000 employees a...
Alice is in New York. Bob is in London. Carol is in Tokyo. They are all editing the same document, the same paragraph, at the same instant. Alice inserts "quick " before "brown". Bob deletes "fox"....
It is 3:47 PM. Magnus, rated 2842, moves his knight to f5 in a blitz game against Hikaru, rated 2798. His clock shows 47.3 seconds remaining. Hikaru has 52.1 seconds. The move must reach Hikaru's s...
It is 5:47 PM on a Friday. Traffic is building across the city. In the next 60 seconds, your platform will process: 4 million tile requests from people panning their screens, 180,000 route computat...
It is 7:42 PM on a Saturday evening. Sarah opens her marketplace app in Brooklyn, searching for a couch within 5 miles. At this exact moment, 63,000 other users across the platform are doing the sa...
It is 9:29 AM Eastern. Sarah opens the Robinhood app on her subway commute, watching NVDA tick up in pre-market. At 9:30:00.003, she taps "Buy 100 shares at market." Her phone shows a spinner for 4...
Ninja announces a surprise Fortnite stream. Within 90 seconds, 627,000 concurrent viewers are connected. Each viewer expects less than 3 seconds of latency from the moment Ninja's webcam captures h...
It is 9:00 AM Monday in New York. Across the world, 2.3 million meetings begin within the same five-minute window — the morning standup surge. In one of these meetings, a CEO in Tokyo needs to hear...
A user types "wireless headphones under $100 with good battery" into your search bar. In the next 120 milliseconds, your system must scan 2 billion documents, understand the query intent, match rel...
Somewhere in a storage cluster, a bit flips. Cosmic ray. Aging disk. Electrical noise. It does not matter why — what matters is that one of your customer's objects now has corrupted data. The custo...
A user in Mumbai opens your app. The home screen needs a hero image, three product thumbnails, a CSS bundle, and two JavaScript files. If these assets load from your origin server in Virginia, each...
A recommendation system looks like a simple retrieval problem. User comes in, you find things they might like, you show them. You could build a working prototype with a nearest-neighbor search and ...
It is 9:47 AM. A user just completed a purchase and is waiting for their confirmation email. They check their inbox — nothing. They check spam — nothing. They check again five minutes later — still...
A real-time analytics platform looks like a straightforward data pipeline. Events flow in, get aggregated, and dashboards show charts. You could prototype one with Kafka and a SQL database in a few...
A distributed lock looks like a simple problem. Store a key-value pair: `lock_X = owned_by_client_A`. Check if the key exists before writing. You could build a working prototype with Redis `SETNX` ...
It is 2:37 AM. Your payment service is experiencing elevated error rates. The on-call engineer identifies the culprit: a misconfigured timeout value pushed an hour ago. They need to roll back immed...
It is 2:47 AM. Your on-call engineer receives a page: "Payment success rate dropped below 99%." They open the dashboard — and it shows no data. The metrics platform is down. Or worse, it is up but ...
A feature flag platform looks simple. Store some boolean values, return them when asked. You could build a working prototype with a config file and an environment variable in minutes.
It is 11:47 AM on Black Friday. Your payment authorization rate just dropped from 97% to 89%. Customer support lines are exploding. Revenue is bleeding. The cause? Your fraud model, retrained yeste...
At 3:47 AM, your payment API returned "success" for a $47.99 charge. The customer saw "Payment Complete." The merchant received a confirmation webhook. Everyone went home happy.
A user submits this code:
Alice in New York sends a message to Bob in Tokyo. Within 300 milliseconds, that message must be written durably, ordered correctly against Bob's other conversations, delivered to his phone and lap...
An observability platform looks like a straightforward data pipeline. Services emit logs, metrics, and traces. You store them somewhere. Dashboards query the data. Engineers debug issues.
It is 8:47 PM on a Friday night. Alex in San Francisco opens the app and starts swiping. At 8:47:32.445 PM, Alex swipes right on Jordan. At that exact same millisecond — 8:47:32.445 PM — Jordan in ...
It is 6:47 AM. Sarah just finished her morning run through downtown San Francisco. Her Garmin syncs to the app. The screen shows: 10.2 km, 52:18 moving time, 312 meters elevation gain. She checks t...
It is 7:14 PM on a Friday evening. Maya opens her app in downtown Manhattan to find nearby friends, restaurants, and events. Within 180 milliseconds, she sees: 4 friends "nearby" (one within 500m, ...
It is 2:58 PM. Sarah clicks "Find a time" hoping to schedule a 30-minute sync with 12 colleagues scattered across New York, London, Berlin, and Singapore. Within two seconds, the calendar must quer...
It is 3:47 PM on a Tuesday. A major tech company announces unexpected layoffs. Within 90 seconds, 2.3 million users open Google News expecting to see the story. The wire services published 47 versi...
The auction timer shows 00:00:03. Marcus's finger hovers over the bid button, ready to outbid the current leader at $4,250 for a vintage watch. He clicks at 00:00:01—the screen freezes, then shows ...
It is Black Friday morning, 3:47 AM Eastern. A PlayStation 5 drops from $499 to $379 on Amazon — a $120 discount that will last exactly 94 seconds before inventory sells out. In your database, 847,...
Player1 fires a headshot at T+0ms while Player2's client still shows them behind cover. By the time that INPUT_CMD packet travels 80ms across the Atlantic, Player2 has already moved. The server mus...
It is the World Cup final. Messi takes a penalty kick at T+0. In living rooms across 200 countries, 847 million viewers are watching — but 12 million of them are tracking the score on their phones ...
Joe Rogan releases a 3-hour episode at 6:00 AM Pacific. By 6:05 AM, 2.1 million podcast apps are polling his RSS feed simultaneously. Within the hour, 800,000 downloads are in progress—each pulling...
A photographer uploads a 47MB RAW image from their DSLR to an e-commerce platform. Within 800 milliseconds, the system must generate a 200x200 thumbnail for the admin panel, a 1200x900 hero image f...
Black Friday, 2:47 AM. Your e-commerce platform's order processing queue has 2.8 million pending tasks. A worker pod crashes mid-execution while charging a customer's credit card for a $3,200 lapto...
A developer accidentally commits an AWS root account key to a public GitHub repository. Within 47 seconds, an automated bot has discovered it and begins spinning up cryptocurrency mining instances....
The product team ships a redesigned checkout flow to 5% of users on a Wednesday morning. By noon, revenue in that cohort has dropped 23%. The experiment platform must detect this regression within ...
Production is down. Forty-seven engineers are frantically searching logs trying to find the root cause of the cascading failure that started twelve minutes ago. There are 2.3 billion log lines from...
Your e-commerce platform launches a flash sale at midnight. Traffic spikes 15x in sixty seconds. Behind the scenes, 2,400 serverless functions spin up simultaneously, each trying to establish its o...
A new payment service version ships to 5% of production traffic. Within three minutes, the canary system detects that p99 latency has spiked from 45ms to 2.3 seconds. Before engineers even notice t...
A distributed lock looks like a simple problem. Store a key-value pair: `lock_X = owned_by_client_A`. Check if the key exists before writing. You could build a working prototype with Redis `SETNX` ...