01

Requirements & scope

Problem Statement & Requirements

Functional Requirements

  • Given a set of seed URLs, systematically crawl the web by following hyperlinks
  • Download and store web page content (HTML, and optionally images/PDFs)
  • Discover new URLs from crawled pages and add them to the crawl frontier
  • Respect robots.txt and crawl-delay directives (politeness)
  • Handle deduplication — don't crawl the same page twice
  • Support prioritized crawling (important pages first)
  • Re-crawl pages periodically to detect changes

Non-Functional Requirements

  • Scalability — crawl billions of pages (the web has ~5 billion indexable pages)
  • Throughput — crawl 1,000+ pages/second per worker, 100K+ pages/second cluster-wide
  • Politeness — never overload a single web server; respect rate limits
  • Robustness — handle malformed HTML, spider traps, infinite loops, timeouts
  • Extensibility — pluggable modules for content extraction, URL filtering, storage backends
  • Freshness — detect and re-crawl changed pages on a schedule

Out of Scope

  • Full-text indexing and search ranking (that's the search engine design)
  • Rendering JavaScript-heavy SPAs (requires headless browser — discussed briefly)
  • Image/video content analysis
02

Scale estimations

Scale Estimations

Web Scale

Metric Value
Total web pages (indexable) ~5 billion
Target crawl coverage 1 billion pages / month
Pages / day ~33 million
Pages / second ~385
With burst / parallelism headroom ~1,000 pages/second
Re-crawl cycle (popular pages) Every 1-7 days
Re-crawl cycle (long-tail) Every 30 days

Storage

Metric Value
Average page size (HTML only) 100 KB
Average page size (compressed) 20 KB
Storage per month (1B pages) 1B × 20 KB = ~20 TB
Metadata per URL ~500 bytes (URL, hash, timestamps, priority)
URL metadata storage (1B URLs) 1B × 500 bytes = ~500 GB
URL frontier (pending URLs) ~100M URLs × 200 bytes = ~20 GB

Network

Metric Value
Bandwidth (downloads) 1,000 pages/s × 100 KB = ~100 MB/s
DNS lookups / second ~1,000 (cached heavily)
Outbound connections ~5,000 concurrent (with connection pooling)

Hardware

Metric Value
Crawler workers 50-100 machines
Pages per worker per second 10-20
Storage nodes 20-30 machines (2 TB SSD each)
DNS cache nodes 2-3 machines
03

Layered architecture

High-Level Architecture

High-Level ArchitectureExcalidraw diagram · editable shapes · reveal step by stepExplore

Detailed Component Architecture

Detailed Component ArchitectureExcalidraw diagram · editable shapes · reveal step by stepExplore
04

API & contracts

Workshop note · added for the website’s common reading format

For Web Crawler, define contracts around the boundary components: Seed URLs, URL frontier, Crawler workers. Specify authentication, request identity, versioning, pagination or streaming semantics, timeouts, and retry behavior. Name which operations are idempotent and how callers discover an uncertain outcome.

The source discusses these contracts within its subsystem walkthroughs rather than as a standalone endpoint catalog. The examples in this article are design exercises, not published service APIs.

05

Data model

Content Storage

Content StorageExcalidraw diagram · editable shapes · reveal step by stepExplore
06

Core design decisions

URL Frontier — The Heart of the Crawler

Two-Level Queue Architecture

The frontier must balance two competing goals:

  1. Priority — crawl important pages first
  2. Politeness — don't hammer any single domain
Two-Level Queue ArchitectureExcalidraw diagram · editable shapes · reveal step by stepExplore

Priority Calculation

Priority CalculationExcalidraw diagram · editable shapes · reveal step by stepExplore
07

Request flows

Crawl Workflow — Step by Step

Single Page Crawl Flow

Single Page Crawl FlowExcalidraw diagram · editable shapes · reveal step by stepExplore

Crawler Worker Internal Pipeline

Crawler Worker Internal PipelineExcalidraw diagram · editable shapes · reveal step by stepExplore
08

Performance & caching

URL Deduplication

The Challenge

  • Billions of URLs to track
  • Must check every extracted URL against "already seen" set
  • Different URLs can point to the same content

URL-Level Deduplication (Before Fetching)

URL-Level Deduplication (Before Fetching)Excalidraw diagram · editable shapes · reveal step by stepExplore

Content-Level Deduplication (After Fetching)

Content-Level Deduplication (After Fetching)Excalidraw diagram · editable shapes · reveal step by stepExplore

DNS Resolution

DNS ResolutionExcalidraw diagram · editable shapes · reveal step by stepExplore
09

Advanced design

Politeness — robots.txt & Rate Limiting

robots.txt Handling

robots.txt HandlingExcalidraw diagram · editable shapes · reveal step by stepExplore

Per-Domain Rate Limiting

Per-Domain Rate LimitingExcalidraw diagram · editable shapes · reveal step by stepExplore

BFS vs DFS Traversal

BFS vs DFS TraversalExcalidraw diagram · editable shapes · reveal step by stepExplore

Distributed Coordination

Partitioning the Crawl Across Workers

Partitioning the Crawl Across WorkersExcalidraw diagram · editable shapes · reveal step by stepExplore

Coordination Service (Zookeeper / etcd)

Coordination Service (Zookeeper / etcd)Excalidraw diagram · editable shapes · reveal step by stepExplore

Re-Crawl Strategy (Freshness)

Re-Crawl Strategy (Freshness)Excalidraw diagram · editable shapes · reveal step by stepExplore

Handling JavaScript-Rendered Pages

Handling JavaScript-Rendered PagesExcalidraw diagram · editable shapes · reveal step by stepExplore
10

Edge cases

Spider Traps & Robustness

Spider Traps & RobustnessExcalidraw diagram · editable shapes · reveal step by stepExplore
11

Tradeoffs

Tradeoffs & Design Decisions Summary

Decision Option A Option B Chosen Why
Traversal DFS BFS (priority-based) Priority BFS Discovers important pages first; DFS gets trapped easily
Partitioning By URL hash By domain By domain Natural politeness enforcement; DNS/robots.txt cache locality
URL dedup HashSet (exact) Bloom filter + DB Bloom + DB 12.5 GB bloom filter handles 99.2% of checks in memory
Content dedup SHA-256 only SHA-256 + SimHash SHA-256 (primary) + SimHash (batch) Exact dedup is fast; near-dedup runs as offline job
Storage S3 only HDFS only HDFS (hot) + S3 (archive) Fast access for indexing; cheap long-term archival
DNS System resolver Custom multi-level cache Multi-level cache 95%+ cache hit rate; pre-fetch for queued domains
Politeness Fixed delay Adaptive (response-time based) Adaptive + robots.txt Respects slow servers; obeys explicit directives
JS rendering Always render Selective render Selective 10x cost; only ~30% of pages need it
Coordination Centralized queue Zookeeper + consistent hash Zookeeper + consistent hash Decentralized work distribution; resilient to worker failure
Re-crawl Fixed schedule Adaptive (change-rate based) Adaptive Changed pages crawled more often; saves bandwidth
Frontier persistence In-memory only Redis/disk-backed Redis (sorted sets) Survives worker restarts; shared across workers
12

Reliability & fault tolerance

Monitoring & Operational Concerns

Monitoring & Operational ConcernsExcalidraw diagram · editable shapes · reveal step by stepExplore
13

Production architecture

Production Architecture

Production ArchitectureExcalidraw diagram · editable shapes · reveal step by stepExplore
14

Further exploration

Workshop note · added for the website’s common reading format

Rebuild Web Crawler from memory, then change one assumption: ten times more traffic, a new region, or a stricter consistency requirement. Which component must change first—and which does not?

Compare Crawler workers with the same boundary in a related design. Write down one alternative you rejected, what it would simplify, and when you would choose it instead. Follow the source link at the end of this article to explore the original document.

15

Interview playbook

Interview Tips

  1. Start with the crawl loop — "Fetch → Parse → Extract URLs → Enqueue → Repeat." Draw this first, then expand each box.

  2. Politeness is critical — Interviewers look for this. Show the two-level frontier (priority + per-domain queues), robots.txt caching, and adaptive delays.

  3. Deduplication has two layers — URL-level (before fetch, bloom filter) and content-level (after fetch, SHA-256/SimHash). Mention both.

  4. Discuss spider traps — This shows real-world awareness. Calendar pages, infinite pagination, and redirect loops are common examples.

  5. Partition by domain, not URL — Explain why: politeness enforcement is automatic, DNS cache locality, no distributed rate limiter needed.

  6. BFS, not DFS — Quick explanation: BFS discovers high-value pages near the root first. DFS goes deep into one site and misses breadth.

  7. Don't forget DNS — A crawler does more DNS lookups than almost any other system. Multi-level caching (in-process → shared → resolver) is essential.

  8. Re-crawl strategy — "How do you keep content fresh?" Adaptive scheduling based on change frequency + conditional HTTP requests (If-Modified-Since).

  9. Scale the numbers — Walk through: 1B pages/month → 33M/day → 385/second → 1000/s with headroom → 50-100 workers. This shows you can think quantitatively.

  10. Mention WARC format — If storage comes up, mentioning the Web ARChive standard shows domain knowledge. "We'd batch pages into WARC files to avoid the small-file problem on HDFS."