How it works
A breadth-first queue discovers a wide graph, but a page can contain thousands of links to its own host. One FIFO queue can flood that host and bury important or recently changed pages. Suppose a popular page adds 10,000 links on one host that allows one request per second. Those URLs need about 2.8 hours, and in a single FIFO they either hammer the host or block workers while other hosts wait behind them.
So split the decision. Give URLs priorities based on the product goal and keep per-host queues or an equivalent host-aware scheduler. A selector picks a valuable URL whose host is eligible, with enough fairness that low-priority hosts are not starved indefinitely. The Mercator research crawler used this separation: priority queues in front, per-host politeness queues behind. The cost is state for every host you know about, and a selector that must skip many waiting hosts efficiently.
At scale, the frontier must survive restarts. Store durable queued and leased state, with small memory buffers for hot operations. Record why a URL is waiting, when it may run, its retry count, and its next recrawl time. A Bloom filter, a compact bit array that answers “definitely new” or “probably seen”, can reject many already-seen URLs cheaply. Ten bits per URL for a billion URLs takes 1.25 GB with about a 1% false-positive rate, and each false positive skips a page you never fetched. It should not be the sole authoritative test when losing a valid page matters.
A popular page links to 10,000 URLs on one host. How should the frontier avoid flooding it?
Keep those URLs in that host’s queue, select only when its delay and concurrency rules permit, and use other eligible host queues meanwhile.
Use this as a guide for self review; written answers are not graded.Keep in mind
- Priority answers which URLs matter; host eligibility answers when they may be fetched.
- Durable queue state and lease recovery prevent lost work.