Skip to interview prep
Apexed

16. Design a URL shortener.

MediumSystem design

Technical

Type or dictate your answer. Your draft is saved on this device.

Show model answer

Clarify scale first (writes vs reads per second, retention, custom aliases, analytics). Core API: create a short code for a long URL, and redirect a short code to its URL.

Generate codes with a counter encoded in base62 or random IDs with collision checks; store code → URL in a key-value store; serve redirects through a cache because reads dominate. Add rate limiting, expiry, and asynchronous click analytics. Discuss 301 vs 302 redirects and how to shard by code.

What interviewers listen for

  • Clarify requirements and scale
  • Read-heavy: cache aggressively
  • Unique code generation strategy
Design a URL shortener. — Software engineering interview question — Apexed