Skip to content

A crawler under hostile and changing inputs

10 min reading

A revision for repeated URLs, destination controls, failures and recrawling

Page details

System Design · Compose complete systems

10 min reading · 25 min with practice

Sources

Published · Last edited:

Prerequisite: A crawler: frontier, fetching and deduplication. For basics, use the independent System Design foundations.

More
20px

Hypothetical scenario. A Northwind supplier changes a redirect target between visits. Another source exposes many addresses with nearly identical bodies. Dev enables retries to improve freshness; Priya asks whether the next connection still reaches an allowed destination.

Dev: “The original hostname passed the collection policy.”

Maya: “What authorizes the actual destination reached after another resolution or redirect?”

Evolve the existing frontier for changing pages, duplicate representations and hostile destinations. Keep the approved host and payload assumptions unless the example explicitly changes them. This is a hypothetical threat exercise, not an accusation about a real supplier.

Which destination will this connection actually reach?

A discovered hostname is not the destination ultimately reached. DNS resolution can produce an address outside the permitted network scope; an HTTP redirect can name another host. Revalidate the scheme, host, port and resolved destination at each connection and redirect. Bind enforcement to the actual connection path, including proxy behavior, so that a check on one address does not authorize a later different resolution.

An approved supplier hostname must not become a route to metadata services, loopback or private service ranges. Prefer an egress boundary that cannot reach protected networks, with explicit exceptions where the product needs them. A URL parser check alone is insufficient if the network path still has broader authority.

Do not forward credentials or confidential headers from one destination to another because a redirect occurred. This collection is for public documents, so a fetch worker should have narrowly scoped storage permissions and no ambient tenant application credentials. Untrusted page content never instructs the worker to relax these controls.

Retain the difference between duplicates and changes

Keep URL identity, representation digest and extracted-document version separate. The same body digest can justify sharing stored bytes. A near-duplicate score is a similarity observation under a chosen text transformation; it is not proof that documents are interchangeable. A changed price or warning can matter even when most words match.

For near-duplicate discovery, shingles turn text into sets of overlapping units. MinHash and locality-sensitive hashing can make candidate comparison cheaper, as the book chapters explain. They introduce an approximate candidate process. Retain enough evidence to inspect errors, and avoid dropping a supplier document solely because an unexplained score says it resembles another.

Conditional HTTP requests can reduce transferred bytes when the origin supports validators. A not-modified result relates to the selected representation and request conditions. It does not prove that a different URL, user context or language variant is unchanged. Keep validator scope attached to the stored fetch record rather than copying it across a deduplicated group.

A revisit must pass current destination and representation checksA scheduled revisit rechecks destination and policy, fetches within bounded resources, and records an exact representation version. Similarity discovery cannot bypass destination or publication checks.Known URL + validatorNext eligible visitCurrent collection scopeResolve + validateCheck every redirectFetch within limitsCompare representationPublish exact versionRetain visit evidence
A revisit must pass current destination and representation checks

Revalidate destination and content meaning on every attempt

Hypothetical scenario. A permitted public URL redirects to another name whose resolved address is private. Apply destination policy to the actual connection destination on redirects and retries, not only to the initial string. Bind resolution, connection and redirect handling so a later lookup cannot silently change the enforced destination.

Revalidate destination and content meaning on every attempt — selected design evidence
Fetch boundaryEvidenceRequired check
ConnectionResolved destinationPublic / allowed address policy
Redirect / retryNew destination + original operationRevalidate each hop
RepresentationValidator, body digest, source timePreserve version meaning
Resource useCompressed / expanded bytes, timeBound work before exhaustion
Destination enforcement precedes connection; response limits remain necessary after a permitted connection.Destination enforcement precedes connection; response limits remain necessary after a permitted connection. Fetch worker to Redirect target: 1 · validate actual destination; Redirect target to Fetch worker: 2 · bounded response; Fetch worker to Parser: 3 · bounded decode + parse.Fetch workerRedirect targetParser1 · validate actual destination2 · bounded response3 · bounded decode + parse
Destination enforcement precedes connection; response limits remain necessary after a permitted connection. Enlarge the diagram to inspect its labels; the surrounding records and explanation give the text alternative.

Conditional requests save body transfer when the server validates the selected representation. A not-modified result still consumes a request and depends on the validator's semantics. A content digest identifies exact bytes; a similarity fingerprint is approximate and cannot safely suppress a small but important policy change without a product rule.

Limit compressed and decompressed bytes, time, redirects and parser work. A small compressed body can demand excessive decompression memory, and a response with little textual change can carry a critical updated price or permission. Allocate recrawl work by the chosen coverage/freshness objective while keeping hostile-response and retry budgets bounded. Store accepted source version and validation evidence so a repeated fetch does not overwrite a newer observation blindly.

Separate saved bytes from saved requests

Hypothetical worked example. Select 10,000 scheduled revisits. Suppose 8,000 receive a not-modified outcome and 2,000 transfer complete bodies of the baseline selected 100,000 bytes. Complete-body payload is 2,000 × 100,000 = 200,000,000 bytes, or 200 decimal MB. Fetching every body would be 10,000 × 100,000 = 1,000,000,000 bytes. The selected difference is 800,000,000 bytes, excluding headers and connection traffic.

There are still 10,000 scheduled requests before redirects or retries. Conditional validation saves body transfer in this example; it does not reduce that request count to two thousand. At the previous selected ceiling of one hundred fetch starts per second, the start-only lower bound is 10,000 ÷ 100 = 100 seconds. Host skew or pauses can make the run longer.

For a toy similarity calculation, let document shingle sets contain six and five distinct elements, with four shared. Their union has 6 + 5 − 4 = 7 elements. Jaccard similarity is 4 ÷ 7, approximately 0.5714. That derived score does not declare whether a changed warning is safe to suppress. Content policy and exact version evidence still determine publication.

In the wild: HTTP validators have request semantics

RFC 9110 defines conditional requests and representation validators. Use those semantics to interpret a response instead of treating a missing body as a failed crawl or a universal statement that nothing changed. Pair that protocol behavior with the collection’s robots and destination policies.

The selected collection can prioritize revisits using observed change history, document importance and time since last successful fetch. Those are local decisions, not predictions guaranteed by a prior unchanged response. A document can change immediately after a successful validation. State freshness in terms of observed fetch evidence and the declared refresh policy.

A retry follows a changed address

Hypothetical failure scenario. The first request times out after a safe resolution. A retry resolves the same hostname to a protected address. The worker trusts its earlier check and connects anyway. Retrying has now crossed a security boundary even though the logical URL did not change.

Move enforcement to each actual connection and keep the egress boundary restrictive. Limit redirect depth, response expansion, per-host retries and total collection work. Record a blocked destination as a distinct outcome; do not conceal it as an ordinary missing page. The control plane can review the supplier configuration without granting the fetcher new authority.

Freshness competes with coverage

Aggressive recrawling spends the same host and worker budget that discovers unseen pages. Select a reviewable priority rule instead of claiming both exhaustive discovery and immediate freshness. Track starvation and the age distribution of retained documents. A single mean age can hide a small group of very stale high-value pages.

Use retries for transient eligible failures within a deadline. Stop retrying a permanently rejected destination, unsupported representation or exhausted collection budget. Quarantine poison documents for inspection with bounded retained bytes. Recovery should not automatically requeue every rejected candidate into the same failure loop.

When a page is removed, preserve a deliberate withdrawn or unavailable state for downstream search. Merely deleting its frontier row can leave the last indexed body discoverable indefinitely. Publication and withdrawal need the same exact document identity and version discipline used in the search chapters.

Challenge the proposed mechanism

A permitted URL is only the first admission condition, not blanket authority for later destinations.A permitted URL is only the first admission condition, not blanket authority for later destinations. URL allowed to Destination rechecked: every redirect / retry; Destination rechecked to Body accepted: size + parse + version checks.URL allowedDestinationrecheckedBody acceptedevery redirect / retrysize + parse + version checks
A permitted URL is only the first admission condition, not blanket authority for later destinations. Enlarge the diagram to inspect its labels; the surrounding records and explanation give the text alternative.

A nearly identical page changes one permission sentence. May a similarity filter discard it?

Reveal the design reasoning

Only under a declared semantics that accepts that loss; it is unsuitable for authoritative policy ingestion. Preserve exact version evidence and evaluate meaningful changes. Also revalidate a retry destination even when the original URL was allowed.

Decision and reconsideration: Keep network authority, byte identity and semantic change separate. Revisit recrawl and deduplication rules when source consequences change.

Check the design against changed conditions

  1. Eight thousand responses omit bodies. Were eight thousand requests avoided?

    Reason through the consequence

    No. The selected revisits still issued ten thousand requests. The example derives body-byte savings, not avoided connections or host scheduling obligations.

  2. A near-duplicate detector gives a high score after a safety notice changes. May the new version be discarded automatically?

    Reason through the consequence

    Similarity is not semantic equivalence. Preserve the exact version and apply an explicit policy for material changes; the score alone cannot establish that the notice is unimportant.

  3. The retry uses the same hostname. May it reuse the earlier destination approval?

    Reason through the consequence

    No. Revalidate the actual resolved connection and every redirect, while maintaining network-level egress restrictions. Stable hostname text does not imply a stable safe destination.

The crawler pair has bounded work from externally supplied inputs. Page 59 starts a shared execution platform and asks how it can accept approved jobs without granting those jobs the control plane’s authority.

Northwind decision log

Recheck every connection and redirect against current destination policy.
Separate URL, exact representation and approximate similarity identities.
Next, give submitted jobs equally explicit acceptance and execution boundaries.

Go deeper: Changing representations and revisit semantics