Curriculum · Module 10, Design Walkthroughs
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
Practise this lesson
8 interview questions on url shortener, with worked answers and sources.
Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms