URL Shortener

Turn long links into short codes and redirect billions of clicks with low latency.

Easy35 minID encodingCachingRead-heavy

A URL shortener turns a long link into a short code like sho.rt/aZ3kQ9p and redirects anyone who visits it. It is a small problem with a very skewed read/write ratio, which makes it ideal for showing ID generation, caching, and data-model reasoning.

Clarify requirements

Functional

  • Create a short URL for a long URL; optionally a custom alias and an expiry.
  • Redirect a short URL to the original.
  • Basic click analytics (count per link, maybe by day and country).
  • Out of scope: user accounts management UI, link editing, spam detection beyond a basic check.

Non-functional

  • 100M new links per month; reads 100x writes.
  • Redirect latency p99 under 50 ms server side.
  • Highly available redirects (99.99%); creation can tolerate slightly lower availability.
  • Short codes must be unique and not trivially enumerable.
  • Links kept for 5 years by default.

Try it first

Set a timer, sketch your own design on paper, then compare it with the reference walkthrough.

35:00

Complete & continue

Defend it out loud

The AI interviewer will probe your design for URL Shortener and score it.

Mock interview