Try
↑ ↓ move↵ openesc close

Curriculum · Module 10, Design Walkthroughs

Lesson 1 · 7 topics · 37 min · Intermediate · 0/7 done

Design a URL shortener

Size the system, then choose how codes are made: counter ranges, random codes or hashes. Collisions follow the birthday bound, hot links belong in a cache, and 301 or 302 decides what you can count.

What each topic covers

  • Turn a long address into a short one and send it back on request. The hard part is making codes that never repeat at a high rate.
  • Pin down what the service must do, size it with simple arithmetic, then sketch the two calls and the one table.
  • Create links with random codes or a counter, click them through a cache, and change code length, cache size and redirect status.
  • Collisions arrive long before the code space is full, and each extra character cuts them by a factor of 62.
  • Three ways to make a code, and what each one costs in coordination, guessability and duplicate handling.
  • A small cache absorbs most clicks. The redirect status decides who caches the answer and what you can count.
  • Three quick checks on collisions, caching and redirect status, with the sources behind the lesson.

Topics

  1. 1A short link is a tiny key-value store4 min
  2. 2Requirements, numbers, API and data model5 min
  3. 3Make codes and follow them in the lab8 min
  4. 4Random codes meet the birthday bound4 min
  5. 5Counter ranges, random codes or hashes6 min
  6. 6Hot links, caches and 301 against 3026 min
  7. 7The URL shortener in review4 min

Practise this lesson

8 interview questions on url shortener, with worked answers and sources.

Practise these

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms