Post

Tech Education

How to Answer "Design a URL Shortener" (and 9 Other Classic System Design Questions)

Short answer outlines for ten classic system design interview questions: URL shortener, rate limiter, news feed, chat, Ticketmaster, YouTube, Dropbox, typeahead, Uber and a web crawler. The key decision in each, the deep dives to expect, and where candidates slip.
By Codemia • November 14, 2026

8 min read

A handful of system design questions come up again and again, at almost every company. They are popular because each one tests a specific idea cleanly: ID generation, fan-out, contention, real-time delivery. If you can answer these ten well, you have covered most of the patterns that harder questions are built from.

Below is a short outline for each: the requirements to confirm, the high level design, the key decision the interviewer is waiting for, and the deep dives to expect. Each one links to the full problem, where you can design it yourself and get it graded.

Use these outlines after you try

Reading an outline before designing a problem teaches you less than you think. Set a 45 minute timer, design the problem from a blank page, then come back and compare. The gaps you find are what you need to study.

1. Design a URL shortener

Confirm: create a short link for a long URL; redirect; optional custom aliases and expiry. Reads far outnumber writes (often 100 to 1).

Estimates: 100 million new links a month is about 40 writes per second, and perhaps 4,000 redirects per second. Five years of links at around 500 bytes each is a few TB.

High level design: a write API that generates a short code and stores code → long URL in a key-value store or relational database; a read path that looks up the code, ideally from a cache, and returns an HTTP 301 or 302.

The key decision: how to generate the code.

  • Hash the URL (for example MD5, take 7 characters): simple, but collisions need handling.
  • Counter plus base62 encoding: a unique number, encoded in 62 characters, gives 3.5 trillion codes in 7 characters. Needs a distributed counter or pre-allocated ID ranges per server.
  • Pre-generated keys: a key service hands out unused codes in batches.

Deep dives: 301 versus 302 (caching versus analytics), cache hit rate on popular links, preventing abuse, and analytics on clicks without slowing redirects.

Practise the URL shortener

2. Design an API rate limiter

Confirm: limit requests per user or API key per time window; distributed across many servers; low latency overhead; what to return when limited (HTTP 429).

High level design: a rate limiting check in the API gateway or as middleware, backed by a shared store such as Redis.

The key decision: the algorithm.

  • Token bucket: allows bursts up to the bucket size, smooth average rate. The most common answer.
  • Fixed window counter: simple, but allows double the limit at window edges.
  • Sliding window log or sliding window counter: more accurate, more memory or computation.

Deep dives: race conditions when two servers update the same counter (atomic operations or Lua scripts in Redis), what to do when Redis is down (fail open or closed), and limits per tier.

Practise the rate limiter

3. Design Twitter (a news feed)

Confirm: post, follow, home timeline. Reads dominate. A small number of accounts have tens of millions of followers.

High level design: a post service writing to a posts store; a social graph store; a timeline service; a cache holding precomputed timelines.

The key decision: fan-out on write or on read.

  • Fan-out on write: when someone posts, push the post ID into every follower's cached timeline. Reads are fast; writes are expensive for big accounts.
  • Fan-out on read: build the timeline when it is opened by merging recent posts from everyone you follow. Cheap writes, slow reads.
  • Hybrid: push for normal accounts, pull for celebrities and merge at read time. This is the answer interviewers want to hear you reach.

Deep dives: the celebrity problem, ranking versus reverse chronological order, media storage, and timeline cache size.

Practise Twitter

4. Design a chat system (Messenger, WhatsApp)

Confirm: one-to-one and group messages, online presence, delivery and read receipts, message history, offline delivery.

High level design: clients hold a persistent connection (WebSocket) to a chat server; a connection registry tracks which server each user is on; messages are stored durably and routed to the recipient's server, or queued for push notification if offline.

The key decision: how a message gets from sender to recipient reliably and in order. Persist first, then deliver; give each message a per-conversation sequence number; the client acknowledges receipt, and the server retries until it does.

Deep dives: group fan-out, presence at scale (heartbeats, and not broadcasting every change), message storage (a wide-column store keyed by conversation and time), and end-to-end encryption.

Practise Facebook Messenger

5. Design Ticketmaster

Confirm: browse events, view a seat map, hold seats while paying, buy. Huge spikes when popular events go on sale. Two people must never buy the same seat.

High level design: event and venue services; a booking service backed by a relational database for seat inventory; a payment integration; a waiting room in front of hot events.

The key decision: seat holds. When a user selects seats, mark them held with an expiry (for example ten minutes) using a conditional update or a distributed lock, so no one else can take them. On payment, convert the hold to a sale; on expiry, release.

Deep dives: a virtual queue to absorb on-sale spikes, caching the seat map without showing sold seats as available, payment failures after the hold, and bots.

Practise Ticketmaster

6. Design YouTube or Netflix

Confirm: upload, process and stream video; very high read volume; many devices and network speeds.

High level design: upload to object storage; a processing pipeline (via a queue) that transcodes each video into several resolutions and splits it into short segments; metadata in a database; segments served through a CDN.

The key decision: the upload-and-transcode pipeline, plus CDN delivery with adaptive bitrate. The player downloads a manifest and picks segment quality based on current bandwidth, switching as the connection changes.

Deep dives: resumable uploads, transcoding cost, which videos to push to edge caches, view counts at scale, and recommendations.

Practise YouTube or Netflix

7. Design Dropbox

Confirm: upload and download files, sync across devices, share, version history. Files can be large and change often.

High level design: clients split files into chunks (for example 4 MB), hash each, and upload only chunks the server does not already have; chunks go to object storage; a metadata service stores which chunks make up each file version; a notification service tells other devices to sync.

The key decision: chunking and deduplication. Only changed chunks are uploaded, which saves bandwidth and storage, and identical chunks across users are stored once.

Deep dives: conflict handling when two devices edit offline (keep both copies), consistency of metadata, notifying devices efficiently (long polling or WebSockets), and storage cost.

Practise Dropbox

8. Design typeahead suggestions

Confirm: suggest the top completions as the user types; under about 100 ms; suggestions reflect popularity and update over time.

High level design: a suggestion service that serves prefix lookups from memory; an offline pipeline that aggregates query logs and rebuilds the data structure periodically.

The key decision: precompute the top results per prefix. Store a trie where each node keeps its top K completions, or a key-value map from prefix to top K list. Lookups become a single read.

Deep dives: sharding by prefix (and the hot prefixes problem), how often to rebuild, trending queries, personalisation, and filtering offensive suggestions.

Practise typeahead suggestion

9. Design Uber

Confirm: riders request a ride, nearby drivers are matched, both see live location, trips are priced and paid. Drivers send location updates every few seconds.

High level design: a location service ingesting driver updates into an in-memory geospatial index; a matching service that queries nearby available drivers; a trip service with a state machine; WebSockets for live updates.

The key decision: the geospatial index. Geohash, quadtrees or a hexagonal grid such as H3 turn "find drivers within 2 km" into a lookup of a few cells. Location data is high write and short lived, so it lives in memory, not the main database.

Deep dives: the write rate of location updates, avoiding two riders being matched to the same driver, surge pricing, and trip state consistency when phones lose connection.

Practise the Uber backend

10. Design a web crawler

Confirm: crawl billions of pages, respect robots.txt and rate limits per site, avoid duplicates, refresh pages over time.

High level design: a URL frontier (queues of URLs to fetch); fetcher workers; a parser that extracts links and content; content storage; a "seen" set for deduplication.

The key decision: the URL frontier. It must prioritise important pages and enforce politeness: one queue per host, so no site is hit too often, with a scheduler choosing which host queue to fetch from next.

Deep dives: deduplicating URLs (normalisation, a Bloom filter) and content (fingerprints), DNS resolution as a bottleneck, crawler traps, and recrawl frequency.

Practise the web crawler

What these ten teach

PatternWhere you practise it
ID generation and cachingURL shortener
Shared counters and atomic updatesRate limiter
Fan-out and precomputed readsTwitter, typeahead
Persistent connections and delivery guaranteesChat, Uber
Contention and correctnessTicketmaster
Async pipelines, object storage, CDNsYouTube, Dropbox
Geospatial indexingUber
Large scale distributed work queuesWeb crawler

Once these feel comfortable, move on to the medium and hard problems in system design practice problems, from easy to hard, or focus on your target company with system design interview questions by company. Keep the system design interview cheat sheet for the night before, and rehearse the outlines out loud with the AI interviewer.