Design a URL crawler
hard 60 minStart 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
| Decision | Choice | Because | I would change it if |
|---|---|---|---|
| Unit of work | Host | Rules belong to hosts | We own the sites |
| Split by | Hash of host | Local politeness | One host is the whole crawl |
| Seen set | Bloom filter | 18 GB; small harm | Every page must be found |
| Duplicates | Hash and SimHash | Dates and adverts change | Exact copies are enough |
| Pages | Packed files | Requests cost more than bytes | Single pages are read often |
| Records | Cassandra | Writes by key | Under 100M URLs |
| Delivery | At least once | Repeats are harmless | Never, here |
| Returns | Learned, capped | Pages differ | Sites push changes to us |
| Consistency | Eventual, one owner for pace | No global locks | Never, here |
When they push back
| They say | Answer 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." |