KatInterview

Design a Distributed Web Archiver with Untrusted Workers

System DesignModel answer
EasyModel answerSystem Designdistributed-systemscrawlingfault-tolerance

Last updated

Design a fault-tolerant system that crawls and versions a large wiki using one coordinator, thousands of unreliable workers, and durable blob storage.

The Problem

Build a distributed archiving system that captures and preserves the full content of a large public wiki — think millions of interlinked pages — and keeps that archive up to date over time.

You have three classes of resources:

  • One coordinator node that is reliable and always available. It manages metadata but cannot route every page body through itself.
  • ~1,000 worker bots that are unreliable and untrusted. They have distinct IP addresses, may crash mid-task, may lie about results, or may return corrupted content.
  • Persistent blob storage (think S3-compatible object store) for durable content.

Your goal is a versioned archive: when a page changes, a new snapshot is stored alongside the old ones rather than overwriting them. Focus on the internals of the archiving pipeline, not on building a reader-facing website.

What to Cover

  • Discovery and frontier management — how you find pages and track what still needs crawling, given the frontier is too large to hold in memory.
  • Deduplication — avoiding redundant fetches and redundant stored blobs.
  • Task assignment and lease management — how work is handed out to workers and reclaimed when they fail.
  • Worker validation and trust — defenses against workers that return garbage, fabricated content, or partial results.
  • Storage and versioning — how content is written, addressed, and published atomically.
  • Recrawl scheduling — keeping content fresh without wasting bandwidth.
  • Coordinator recovery — what happens if the coordinator restarts.

Constraints and Assumptions

  • Workers can disappear at any point, retry a task without telling anyone, or submit results for tasks they were never assigned.
  • The coordinator tracks metadata (URLs, state, checksums, lease expiry) but page bodies flow directly from workers to blob storage.
  • Pages link to other pages; the link graph is not known ahead of time.
  • Crawling must respect the site's robots policy and rate limits.
  • A snapshot is only marked "published" after its content and provenance have been verified.
  • Decide for yourself whether to use official data dumps or APIs to bootstrap coverage; justify the trade-off.

Hints

Hint 1

Start with frontier state: each URL needs a lifecycle — unseen, leased, done, failed. What data structure backs that at scale, and how does it survive a coordinator restart?

Hint 2

Leases are your primary tool against worker failure. Think about what happens when a lease expires: who detects it, how is the task re-queued, and how do you avoid two workers publishing conflicting results for the same URL?

Hint 3

Untrusted workers need more than a timeout. Consider content hashing, cross-worker redundancy for suspicious results, and what a 'validation gate' looks like before a snapshot is promoted to published.