InterviewDryRun
System design interview · Asked at mid and senior level

Design a URL Shortener

How the interviewer asks it

“Design a service that turns long URLs into short links, redirects visitors quickly, and counts clicks.”

Want the full answer? Watch lesson 1 of the free system design course: a 21-minute video walkthrough of this question.

Typed drills are free and unlimited: the AI scores your answer against the outline below.

What the interviewer is looking for

  • You size it first: writes per second, redirects per second, total links over five years, and the read-to-write ratio.
  • A deliberate choice of key generation (counter with base62, random keys with collision checks, or a key range service) with trade-offs.
  • A fast redirect path: cache in front of the store, and a reasoned choice of 301 versus 302.
  • Click counting kept off the redirect path, through a queue or log.
  • You find the hot spot yourself: one viral link.

How to structure your answer

  1. 01

    Requirements

    Create, redirect, optional custom alias and expiry, click counts. Non-functional: redirect latency, availability over consistency, links that never collide.

  2. 02

    Estimates

    For example 100 million new links a month and 100:1 reads: roughly 40 writes and 4,000 redirects a second on average, several times that at peak, a few terabytes over five years.

  3. 03

    API and data model

    POST /links returns the code; GET /{code} redirects. A table keyed by code with the long URL, owner, created and expiry.

  4. 04

    Key generation

    Seven base62 characters give about 3.5 trillion keys. Hand out counter ranges to each app server, or generate random keys and retry on conflict.

  5. 05

    Read path

    CDN or edge cache, then an in-memory cache, then a key-value store partitioned by code. Use 302 if you need every click counted.

  6. 06

    Analytics and scale

    Emit click events to a log and aggregate asynchronously. Replicate the store across regions and discuss what happens when a cache node fails.

Best answers from candidates

No candidate answers yet. Type yours, and if it scores 6 or more you can show it here without your name.

Answers are shared by candidates, without names, after a privacy check. Add yours

Common mistakes

  • Drawing boxes before agreeing on requirements and numbers.
  • Hashing the long URL and truncating it without a collision plan.
  • Writing a row to the database on every redirect for analytics.
  • Ignoring abuse: spam and malicious links, rate limits on creation.

Follow-up questions to expect

  • A link goes viral: 50,000 redirects a second to one key.
  • Users want custom aliases. How do you stop two people claiming the same one?
  • How do you delete expired links without scanning the table?

Now answer it out loud

Max will ask you this exact question, listen to your answer, push on the weak spots with follow-ups like the ones above, and score you when you finish.

Practice with Max

Free: a 5-minute voice round and unlimited typed drills, with scored feedback. No card, and your camera is never recorded.

More system design interview questions

Preparing for this round? Read how to practice for a system design interview.