LESSON 04 · Durable URL frontier

Schedule useful URLs

Combine priority, fairness, and host eligibility instead of using one naive FIFO queue.

SYSTEM VIEW

The crawl path

Diagram view
Host A queue—
Drain time—
Seen set—

Watch 10,000 links for one host jam a single queue, then see the frontier sort them by value and by host.

  1. The Parser reads a popular page on host A and finds 10,000 links to host A’s own pages. A breadth-first crawler puts them all in one FIFO queue, first in, first out, and host B’s links, found next, line up behind them.

    Host A links
    10,000
    Order
    first in, first out

    What changed

    • 10,000 host-A URLs in one FIFO
    • Host B’s URLs behind them
  2. The Fetch worker takes the next URL in line as fast as it can, and the next 10,000 are all for host A. Host A allows 1 request a second, but one FIFO knows nothing about hosts, so nothing holds the line back.

    Host A allows
    1 request/s
    The worker takes
    next in line

    What changed

    • Host A flooded past 1 request/s
  3. Held to host A’s 1 request a second instead, the 10,000 URLs need about 2.8 hours. The Fetch worker sits blocked between requests, and host B’s links, with any important page found later, wait behind them the whole time.

    10,000 URLs
    about 2.8 hours
    Host B
    waits behind

    What changed

    • Host A held to 1 request/s
    • Worker blocked between requests
    • Host B waits about 2.8 hours
  4. So split the decision. The Prioritizer takes the place of the single line and ranks each link by the product’s goal: important or recently changed pages first. Priority answers which URLs matter, not when a host may be fetched.

    What changed

    • Prioritizer, in the FIFO’s place
    • Links ranked by value
  5. Behind it, the URL frontier keeps a row per host. The Host timer holds each host’s next-eligible time, the earliest its next request may go; host A’s is 1 second away. The Mercator research crawler used this split: priority queues in front, per-host politeness queues behind.

    Row 1
    host A: 10,000
    Row 2
    host B
    Row 3
    host C, low priority

    What changed

    • URL frontier, a row per host
    • Host timer
    • Host A next in 1 s
  6. A selector takes the most valuable URL whose host is eligible. Host A must wait, so host B’s URL goes first, then host A’s once its second is up. Low-priority host C isn’t starved. The cost: state for every host, and a selector that skips waiting hosts quickly.

    Fairness
    host C gets a turn
    Cost
    state for every host

    What changed

    • Host B’s URL while host A waits
    • Host A’s URL once eligible
    • Host C’s URL, not starved
  7. The URL frontier keeps queued URLs, and leased ones claimed by a worker for a limited time, in durable storage with small memory buffers for hot operations. Per URL it records why it waits and when it may run. After a restart, host A still has 9,999 waiting.

    Per URL
    why waiting, when it may run
    Also
    retries, next recrawl

    What changed

    • URL frontier restarts
    • Queued and leased URLs restored
    • Host A still has 9,999 waiting
  8. The URL-seen set is a Bloom filter, a compact bit array: 10 bits per URL hold a billion URLs in 1.25 GB. About 1% of new URLs get “probably seen” instead of “definitely new”, so link 2 is never fetched. Don’t make it the only test where losing a page matters.

    Bits per URL
    10
    1 billion URLs
    1.25 GB
    False positives
    about 1%

    What changed

    • URL-seen set, a Bloom filter
    • Link 1 definitely new
    • Link 2 skipped, never fetched

Space plays · ← → step · Home resets

THE IDEA

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.

DECISION POINT

A popular page links to 10,000 URLs on one host. How should the frontier avoid flooding it?

Write a sentence or two to unlock the guidance. Committing first is what makes it stick.

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.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 2
RecallQUESTION 01

What are the two core scheduling decisions?

Choose an answer. You’ll see the explanation once you get it right.

Next lesson

0 of 2 checkpoints answered correctly to complete this lesson.