System Design Advanced

05  Capstone: URL Shortener

The classic, end to end. A URL shortener looks trivial until the numbers arrive -- which is exactly why it tests everything at once: estimation, key design, storage, caching, and the evolution story when product asks for more.

Step 1 / 2

Design a URL shortener end-to-end for: 100 million new links per month, 10 billion redirects per month, links must keep working for years. Cover: the API, short-key generation (length, alphabet, collision story), the storage schema with a size estimate, the redirect read path with caching, and your QPS numbers.

Hints
  • Numbers first: 100M/month is about 40 writes/s; 10B/month is about 4,000 redirects/s. The 100:1 read ratio should drive the whole design.
  • Base62 over 7 characters gives 62^7, about 3.5 trillion keys. Generate from a counter (collision-free, guessable) or randomly (check-and-retry) -- pick one and defend it.
  • The redirect path should almost never touch the database: short-key mappings are immutable, which makes them the easiest thing in the world to cache.
Your design is reviewed against a hidden rubric.