AlgoViz

Design a URL crawler

hard 60 min

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

Explain your choices

Answer first. Then compare your reasoning.

12 questions 0 got it 0 to review12 not marked

Summary

Decisions

DecisionChoiceBecauseI would change it if
Unit of workHostRules belong to hostsWe own the sites
Split byHash of hostLocal politenessOne host is the whole crawl
Seen setBloom filter18 GB; small harmEvery page must be found
DuplicatesHash and SimHashDates and adverts changeExact copies are enough
PagesPacked filesRequests cost more than bytesSingle pages are read often
RecordsCassandraWrites by keyUnder 100M URLs
DeliveryAt least onceRepeats are harmlessNever, here
ReturnsLearned, cappedPages differSites push changes to us
ConsistencyEventual, one owner for paceNo global locksNever, here

When they push back

They sayAnswer with
"Just use Kafka as the frontier.""A log gives order of arrival. I need order by value and by time for each host, and to skip hosts that rest. I use Kafka for what comes after."
"Ten shards for 400 pages a second?""For memory and failures, not for speed. With 100M URLs I would run one and a spare."
"Kafka is exactly once, so no duplicates.""Inside Kafka, with transactions. A fetch from the web is outside. I make storing idempotent instead."
"More IP addresses would speed it up.""They spread our load. Using them to exceed a host's limit would break the promise."
"Is all this needed?""No. Version 2 is a good crawler for tens of millions of pages."