KatInterview

Design an Up-To-Date Knowledge Base Page Crawler

System DesignModel answer
MediumModel answerSystem Designsystem-designdistributed-systemsweb-crawler

Last updated

Design a distributed web crawler and storage architecture that guarantees every page in a target wiki is updated at least once every five days.

Design a large-scale crawling and storage system for a comprehensive online wiki. The primary objective is to maintain an accurate, historical store of all wiki pages while guaranteeing that no stored page is ever more than five days out of date relative to the live site.

Scope & Scale Assumptions

Clarify and state explicit capacity requirements before diving into architecture. For this problem, assume:

  • Total Pages ($N$): 50 million distinct articles/pages.
  • Average Page Size: 100 KB (including raw markup, HTML, and essential metadata; external media such as full-resolution images/videos are out of scope).
  • Target Freshness Threshold ($T_{max}$): 5 days ($432,000$ seconds).
  • Interface Availability: The system must rely on standard HTTP crawling and API endpoints (e.g., MediaWiki APIs or Change Feeds if available), while respecting site politeness guidelines.

Requirements & Key Aspects to Address

  1. Back-of-the-Envelope Calculations: Calculate the necessary throughput (pages/sec, bandwidth) and total storage required to meet the 5-day freshness SLA.
  2. System Architecture: Detail the pipeline components (URL discovery, scheduler/frontier, fetcher workers, change detector, storage engine).
  3. Freshness & Scheduling Strategy: Explain how the scheduler guarantees the 5-day SLA across all pages while prioritizing high-churn pages.
  4. Storage Architecture: Describe how page contents, versions, and crawl metadata are persisted and indexed efficiently.
  5. Politeness & Resilience: Address rate-limiting, error handling, retries, and SLA monitoring.