In this lesson · topic 7 of 7
Topic 7
The URL shortener in review
4 min read
Predict first
Predict first
Predict first
Take away
- A short link service is a key-value store whose hard part is making unique codes at a high rate.
- Size it first. A hundred million links a month is tens of writes a second and thousands of reads a second.
- Counter ranges never collide and are guessable. Random codes need a check and retry. Hashes de-duplicate and also need a check.
- Collisions follow the birthday bound. Each extra character cuts them by a factor of 62.
- Clicks are skewed, so a cache sized from the click curve takes most reads. The code scheme does not change the hit ratio.
- A 301 saves load and hides clicks. A 302 keeps the server in the path.
Sources
- Roy Fielding, Mark Nottingham, Julian Reschke, RFC 9110: HTTP Semantics, IETF, 2022.
- Roy Fielding, Mark Nottingham, Julian Reschke, RFC 9111: HTTP Caching, IETF, 2022.
- Lee Breslau, Pei Cao, Li Fan, Graham Phillips, Scott Shenker, Web caching and Zipf-like distributions: evidence and implications, IEEE INFOCOM, 1999.
- David Karger et al., Consistent hashing and random trees, ACM STOC, 1997.