Design a Web Crawler and Inverted Index
Continuously crawl an allowed web corpus and build a fresh, deduplicated inverted index for keyword search.
Problem statement
For this exercise, assume that a crawler discovers an allowed URL, fetches and canonicalizes it, indexes its terms, and later serves a keyword query from a fresh generation. Accept seed URLs and discover normalized links while enforcing scope and per-host politeness.
Schedule resilient conditional fetches with bounded retries and content-size limits. Parse supported documents and maintain term-to-document postings with versioned generations. Return ranked keyword results and expose crawl/index freshness.
Assume a one-billion-page allowed corpus, 50,000 fetches per second, and an average compressed page size of 100 KB. Respect per-host crawl budgets and publish 99 percent of successful changes to search within fifteen minutes. Retain two index generations for rollback and never fetch disallowed or private address space.
Preserve this invariant: one canonical content version is indexed once per generation and host policy is checked before every fetch. Keep unrelated product features and company-specific infrastructure outside the first version.
What to build
- Accept seed URLs and discover normalized links while enforcing scope and per-host politeness.
- Schedule resilient conditional fetches with bounded retries and content-size limits.
- Parse supported documents and maintain term-to-document postings with versioned generations.
- Return ranked keyword results and expose crawl/index freshness.
At scale
- For this exercise, assume a one-billion-page allowed corpus, 50,000 fetches per second, and an average compressed page size of 100 KB.
- For this exercise, respect per-host crawl budgets and publish 99 percent of successful changes to search within fifteen minutes.
- For this exercise, retain two index generations for rollback and never fetch disallowed or private address space.