Try
↑ ↓ move↵ openesc close
In this lesson · topic 7 of 7
  1. 1. A short link is a tiny key-value store
  2. 2. Requirements, numbers, API and data model
  3. 3. Make codes and follow them in the lab
  4. 4. Random codes meet the birthday bound
  5. 5. Counter ranges, random codes or hashes
  6. 6. Hot links, caches and 301 against 302
  7. 7. The URL shortener in review

Topic 7

The URL shortener in review

4 min read

Predict first

Why can random 7 character codes collide long before 3.5 trillion links exist?

Predict first

You add counter ranges so many servers can make codes. What does a server ask the coordinator for?

Predict first

A team switches from 302 to 301 to cut load. What do they lose?

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

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