Design a URL Shortener

16 min read

This is your first full design, step by step, like in a placement interview. You will design a service that turns a very long link into a short one. You will use the same eight steps for any system design question.

New words

Requirement
Something the system must do, or a limit it must keep.
QPS
Queries per second: how many requests reach your system each second.
Base62
A way to write a number using 62 symbols: 0-9, A-Z and a-z.
Redirect
A reply that tells the browser to go to a different link.
Cache
A small, fast store for answers that people ask for again and again.
Replica
A copy of the database that is used to answer read requests.
Single point of failure
One part that, if it breaks, stops the whole system.

What you will learn

  1. The problem: a very long link
  2. Step 1: Requirements
  3. Step 2: Small estimates
  4. Step 3 and 4: The API and the data
  5. Step 5: Making the short code
  6. Try it: a working URL shortener
  7. Step 6: The design
  8. Step 7: Growing the system
  9. Step 8: What can go wrong?
  10. Trade-offs in this design
  11. In a real system
  12. Interview tip
  13. Key takeaways

10 quiz questions at the end.

Start this lesson

The full lesson, with interactive demos and the quiz, opens after you sign in with Google. It is free.

All lessons · Back to the roadmap