teacher
Sign in

Design a URL Shortener

A full case study of a TinyURL-style service, covering short-code generation, a read-heavy store, caching and redirect trade-offs.

35 min5 interactive

Requirements

A URL shortener turns https://example.com/very/long/path?x=1 into something like https://sho.rt/aZ3k9Qp. Visiting the short link redirects to the original.

Functional:

  • Create a short link from a long URL.
  • Redirect a short link to its long URL.
  • Optional expiry; optional custom alias.

Non-functional:

  • Redirects are fast, ideally under 50 ms server time, and highly available. A broken link is a visible failure.
  • Short codes are unique and hard to guess one by one.
  • Reads vastly outnumber writes.

Out of scope for this lesson: user accounts, abuse and phishing detection (real services need both).

1 of 10