KatInterview

Designing a Polite, Scalable Web Crawler at Production Scale

System DesignModel answer
MediumModel answerSystem Designsystem-designrate-limitingweb-crawler

Last updated

Design a distributed crawler that fetches pages quickly across many hosts while never overloading any single upstream, with safe retries, deduplication, fairness and monitoring.

A simple graph traversal over web pages now has to run as a production service. Visiting a page means making an outbound HTTP or API request to discover its outgoing links, and the servers you call may enforce tight rate limits or fall over if hit too hard.

Design a crawler that:

  • Covers a very large set of pages or resources efficiently
  • Does not let any single host become a throughput bottleneck for the whole system
  • Never overloads the services it calls, even by accident
  • Deals with retries, timeouts and partial failures safely
  • Scales out across many workers or machines

In your answer, cover:

  1. Requirements, scale assumptions and back-of-envelope numbers
  2. Overall architecture and the data model
  3. Concurrency model and request scheduling
  4. Deduplication of URLs and content
  5. Rate limiting and backoff
  6. Fairness across domains
  7. Failure handling
  8. Observability and operational controls

State your assumptions explicitly and explain the trade-offs behind your main choices.

Hints

Hint 1

Ask what the real bottleneck is. If a site accepts one request per second, what limits how fast you can finish crawling it, and where can parallelism actually help?

Hint 2

Consider partitioning the work queue by host so that exactly one scheduler owns each host. What does that do to the difficulty of enforcing per-host rate limits?

Hint 3

Use Little's law (concurrency = throughput x latency) to size the number of in-flight requests, and think about which signals (429, Retry-After, rising latency, consecutive errors) should slow a host down.

Hint 4

Retries must never bypass throttling. Think about routing them back through the same scheduler, with jittered exponential backoff, a retry budget, leases for crashed workers, and a dead-letter queue.