Design a URL shortener
Build a service like bit.ly that turns long URLs into short links and redirects visitors to the original address.
Functional requirements
- Create a short link from a long URL
- Redirect a short link to its original URL
- Optional custom alias and expiry date
Non-functional requirements
- Redirects under 50 ms at p99
- Highly available: links must always resolve
- Short codes must not collide
Scale
- 100M new links per month
- Read to write ratio of about 100:1
- Links kept for 5 years
How you’ll be scored
7 checks covering your diagram and your notes, and any valid approach counts. Hints appear for anything you miss. Common mistakes, such as single points of failure or components you never explain, cost points. How grading works
What interviewers look for
- Clarify before you draw. State what is in and out of scope. For “Design a URL shortener”, that starts with: Create a short link from a long URL; Redirect a short link to its original URL; Optional custom alias and expiry date. Interviewers notice candidates who pin the requirements down first.
- Turn the scale into numbers. The scale (100M new links per month; Read to write ratio of about 100:1; Links kept for 5 years) should become requests per second, storage and bandwidth, and those figures should drive your choices. Estimates with units carry more weight than adjectives.
- Show how each quality is met. Your design should visibly deliver: Redirects under 50 ms at p99; Highly available: links must always resolve; Short codes must not collide. Saying that it does isn’t enough; point to the part of the design that makes it true.
- Expect follow-ups on the hard parts. Interviewers usually probe hashing, caching and read-heavy here. This is an easy problem, so interviewers expect the fundamentals done cleanly: a clear request path, the right kind of data store, and a reason for each component.
- Explain failure and trade-offs. Say what happens when a component fails, where a single point of failure would hurt, and what you chose not to build. Naming a trade-off is a stronger answer than claiming there isn’t one.