7
Back to Problem Dungeon

URL Shortener

medium

Step 1: Requirements

Requirements

Questions to ask the interviewer

  • What is the expected scale? (reads vs writes ratio)
  • Do we need custom aliases (e.g. short.ly/my-brand)?
  • Should short URLs expire (TTL)?
  • Do we need click analytics (who clicked, when, from where)?
  • Is there a character limit on the short code?
  • Do we need to handle duplicate long URLs (return the same short URL)?

Functional requirements

  1. Given a long URL, generate a unique short URL
  2. Given a short URL, redirect to the original long URL
  3. Support custom aliases
  4. Support optional expiration (TTL)
  5. Track click analytics (timestamp, referrer, user-agent)

Non-functional requirements

  • Read-heavy (100:1 read-to-write ratio)
  • Low latency redirects (< 50ms)
  • Short codes should be URL-safe and compact (6-8 chars)
  • High availability — redirects must not fail

1 / 7 — Requirements