AlgoViz

Design a URL crawler

hard 60 min

Start from a few addresses, download pages, find links, and repeat a billion times a month.

Remember it

The few things worth knowing cold, and how to make them stick.

Memory hook

One ant in the doorway, one second each: hosts, not servers, set the pace.

Ants explore tunnels, leave a flag where they have been, queue politely at a narrow door, share the chambers, and return to the mushrooms that grow fast.

Cheat sheet

Rate
386/s, 1,157/s at peak
Link checks
30,900/s; 92,600 at peak
Seen set
18 GB, 0.1%, 10 hashes
Pages
12.5 TB a month compressed
URL records
3 TB for 10 billion
Pace
1 request a second, 1 connection, per host
robots cache
24 hours at most
SimHash
64 bits, 3 may differ
Limits
5 redirects, 10 MB, 30 s, depth 15

Spot it when you see

  • Discover and process an endless graph
  • Calling many strangers' servers with limits
  • A set too large for memory where small errors are fine

Tricks that stick

  • Four letters: P for priority in front, P for politeness at the back.
  • 4xx opens, 5xx closes.
  • Bits for a Bloom filter: about 4.8 for each factor of ten in the error rate.

Do not forget

  • A shared counter for politeness
  • Scanning the URL table for due pages
  • One object for each page
  • Trusting canonical links and dates blindly
  • Following redirects into a private network