System design case study C17 · Pipelines · Dedupe

Design a Web Crawler

Download billions of pages politely, avoid fetching the same thing twice, and don't get trapped in infinite calendars, all while the web keeps changing.

What you'll be able to explain
  • Design a URL frontier with priority and politeness
  • Deduplicate URLs and content at scale
  • Respect robots.txt and per-host rate limits
  • Defend against spider traps
  • Schedule re-crawls by change rate

Scope

Functional

  • Start from seed URLs; fetch pages; extract links; store content for indexing.
  • Respect robots.txt; re-crawl pages based on how often they change.
  • HTML only (images/video out of scope).

Non-functional

  • 1B pages/month initially, growing. Polite: never overload any site.
  • Robust to malformed pages, slow servers and traps.

Size

  • 1B pages/month ≈ 400 pages/s average; plan for ~1,000/s.
  • Average page 100 KB (compressed ~25 KB) → 25 TB/month stored.
  • URL-seen set: ~10B URLs × 8-byte fingerprint ≈ 80 GB (plus Bloom filter in memory).

The pipeline

CLIENTSeed URLsQUEUE / LOGURL frontierpriority + per-host queuesWORKERFetchersasync HTTPCACHEDNS cacheCACHErobots.txt cacheOBJECT STOREContent storeobject storageWORKERParserlinks + textSERVICEContent dedupeSimHashSERVICEURL filterseen? allowed?new linksunseen
Crawler pipeline: frontier → fetch → parse → dedupe → back to frontier.

The 30-second summary

Say it in the interview

"A distributed pipeline: a disk-backed frontier with priority front queues and per-host back queues, partitioned by host hash so each host has one owner and politeness is local. Async fetchers with DNS and robots caches store raw pages in object storage; parsers extract links, which are normalised and checked against a Bloom-filter-backed seen-set; near-duplicate content is filtered with SimHash. Trap limits and change-rate-based re-crawling keep it efficient."

Follow-up questions the interviewer may ask

  1. How do you avoid crawling the same content twice?
  2. How do you decide what to recrawl?
  3. How do you handle crawler traps?
  4. How do you crawl JavaScript-heavy pages?

Model answers to each of these are in the book.