11. Classic design problemsURL shortener
URL shortener
A URL shortener is a service like bit.ly: you give it a long web address and it hands back a short link, and anyone who visits the short link gets redirected to the original. Under the hood it’s a lookup table from short code to long URL, read far more often than written, so a cache in front of the database does most of the work. The interesting design question is how to generate the codes: a counter turned into letters and digits (base62) is compact and never collides but needs coordination across servers, while random or hashed codes need no coordination but must be checked for collisions.
In this lesson: ID generation choices on the architecture canvas.