KatInterview

Streaming Design for Cleaning and Near-Duplicate Removal of Web Crawl Text

System DesignModel answer
MediumModel answerSystem Designsystem-designstreamingminhash

Last updated

Design a horizontally scalable streaming system that extracts text from 100TB of crawled HTML, filters it, removes near-duplicates and reports live metrics, all in one pass.

Your team is preparing pretraining data for a large language model. The raw material is 100 TB of crawled HTML pages. Design a streaming system that turns it into a clean, filtered, near-duplicate-free English text corpus. It must do so in one pass, without writing intermediate copies of the pages back to storage.

What the system must do

  1. Text extraction: Turn each HTML page into normalized plain text, removing navigation, ads, scripts, styles and other boilerplate.
  2. Quality gates: Reject documents that are too short, contain too many non-alphanumeric characters, or are not identified as English by a language classifier.
  3. Near-duplicate removal: Detect and drop documents that are very similar to ones already seen in the stream, without a lookup against one giant global table.
  4. Live metrics: Report throughput, per-filter rejection rates and the distribution of document lengths as the job runs.

Constraints

  • Horizontal scale: The design must keep working at 100 TB and beyond by adding machines, with no single choke point.
  • Memory: Each worker has 32 GB of RAM, so the full dedup index cannot live in memory on one node.
  • Failure handling: If a node dies, the job must resume from recent progress rather than restart from scratch, and every surviving document must appear in the output exactly once.

What to deliver

Describe the architecture and name the technologies you would use for ingestion, processing and storage. Explain in detail how fuzzy deduplication works without a global full-table lookup, and how you would track metrics in real time. Back your choices with rough capacity numbers and discuss trade-offs.

Hints

Hint 1

Start with arithmetic: estimate the document count, the text volume after HTML removal, and the cores needed to finish in a fixed window such as 24 hours.

Hint 2

Do not push raw HTML through a message broker. Send small pointers (file and byte range) through the queue and let workers read bytes from object storage.

Hint 3

MinHash signatures split into LSH bands give you keys that can be hash-partitioned. Each state-holding worker owns a slice of the index, so no node needs the whole table.

Hint 4

Think about delivery guarantees explicitly: checkpointed state plus a transactional (two-phase commit) sink gives exactly-once output after a crash.