KatInterview

Architecting a Scalable, Politeness-Aware Web Crawler

System DesignModel answer
HardModel answerSystem Designsystem-designdistributed-systemsconcurrency

Last updated

Design a high-throughput, distributed web crawling system that manages per-domain rate limits, prevents duplicate fetches, and handles network resilience at scale.

Design a large-scale distributed web crawler capable of continuously discovering, fetching, and persisting hundreds of millions of web pages per day across the public internet.

Requirements

  1. Host Politeness & Compliance: Strictly observe rules defined in robots.txt files and enforce configurable per-domain request throttles (e.g., ensuring a mandatory delay between successive requests to the same hostname).
  2. Horizontal Scalability & High Throughput: Efficiently scale out across a pool of stateless workers to crawl at least 100 million distinct documents per day.
  3. Multi-Stage Deduplication: Prevent redundant network requests and duplicate content storage by identifying seen URLs and duplicate document bodies.
  4. URL Normalization & Redirect Tracking: Consistently format discovered URLs, resolve relative hyperlinks, strip non-semantic query params, and follow HTTP redirect chains safely.
  5. System Fault Tolerance: Guard against worker crashes, non-responsive target servers, malformed HTML markup, and crawler traps.

Expected Output

  • Provide a back-of-the-envelope capacity estimate (throughput, bandwidth, storage, and worker concurrency).
  • Describe the high-level system architecture and data flow.
  • Detail the design of the URL Frontier (priority vs. politeness management).
  • Explain the multi-layer deduplication mechanism (URL filtering and content hashing).
  • Outline failure handling strategies, including circuit breakers and parsing isolation.

Assume access to standard infrastructure components (message queues, distributed key-value databases, object storage, and distributed caches).

Hints

Hint 1

Decouple URL scheduling from network workers: use the Mercator model (priority queues feeding into host-specific politeness queues).

Hint 2

Partition host scheduling by consistent hashing on the domain name so that rate limits and robots.txt rules can be evaluated locally without distributed locks.

Hint 3

Implement deduplication in two stages: a light, probabilistic Bloom filter check before scheduling, and a content-hash check after downloading.