Web Crawler
Systematically download and index the web at scale. Breadth-first, politeness-aware.
The program is four lines. Fetch a page, pull out the links, add them to a list, repeat.
Run it and within a minute you have hammered one site with a thousand requests and been banned, followed a calendar that generates a new page for every day until the year 3000, downloaded the same article at nine different addresses, and filled your disk with a video you never wanted.
None of that is a bug in the four lines. The web is a graph full of loops and mirrors, some of it is deliberately hostile to programs like yours, and the polite conventions are not enforced by anything except you.
Every real crawler is a distributed system wrapped around that loop to stop it destroying both its target and itself, and at a billion pages a month the constraint is not speed. It is bandwidth, storage, and not getting banned.
Lessons
4 in this chapter- Requirements and EstimationOne billion pages a month is only 385 fetches per second, and bandwidth is the bill.2 min
- The Crawl PipelineFrontier to fetcher to parser and back to frontier, with every stage independently scalable.3 min
- The Frontier and PolitenessThe frontier is not a queue, it is a scheduler that must never point two workers at one domain.2 min
- Deduplication and StorageA bloom filter guards the frontier, content hashes catch mirrors, and everything drains to an object store.3 min