System DesignOct 3, 2026⏱️ 2 min read
Design a Scalable Web Crawler: URL Frontier, Politeness, Bloom Filters & Deduplication

Design a Scalable Web Crawler: URL Frontier, Politeness, Bloom Filters & Deduplication

Crawling Billions of Pages Without Breaking the Web

Web crawlers power search engines (Googlebot), AI retrieval pipelines, price monitoring, and copyright compliance. At 1 billion pages per month (~400 pages/sec average, 800+ peak, ~400 TB/month raw HTML), the hard engineering challenges are politeness, deduplication, and avoiding infinite spider traps.
Distributed Web Crawler Architecture

Distributed Web Crawler Architecture


1. End-to-End Crawling Pipeline

[Seed URLs] ──► [URL Frontier] ──► [HTML Downloader] ──► [Content Parser]
                     ▲                 (DNS Cache +           │
                     │                  robots.txt)           ▼
               [URL Seen? / Filter] ◄── [URL Extractor] ◄── [Content Seen? (SimHash)]
  1. Seed URLs: High-authority entry points partitioned across regions/topics.
  2. URL Frontier: Two-stage queue system balancing priority and politeness.
  3. HTML Downloader: Fetches pages asynchronously (asyncio/epoll), honoring robots.txt rules cached locally per host.
  4. Content Parser & Dedup: Strips invalid markup and fingerprints text to avoid indexing duplicate mirrors (~29% of web pages are duplicates!).

2. Deep Dive: The Two-Stage URL Frontier

Never send 50 parallel crawler threads at the same website—that effectively DDoS's small servers and gets your IP banned.
         ┌──► Priority Queues (High / Med / Low PageRank)
URLs ────┤         │
         │         ▼ (Router maps host -> single worker queue)
         └──► Back Politeness Queues:
                ├── Queue 1: wikipedia.org (1 req / 2 sec)
                ├── Queue 2: python.org    (1 req / 2 sec)
                └── Queue 3: arxiv.org     (1 req / 5 sec)
  • Front Queues (Priority): Rank URLs by authority, update frequency, or traffic.
  • Back Queues (Politeness): Each worker thread reads from a dedicated FIFO queue bound to one hostname (via a hash table host -> queue), enforcing a delay (last_fetch + delay) between requests to that domain.

3. High-Performance Optimizations

  • Local DNS Resolver: Standard synchronous OS DNS lookups block threads for 10–100ms. Run a dedicated local caching DNS service (Unbound / in-memory map) refreshed asynchronously.
  • Content Deduplication (SimHash / Locality-Sensitive Hashing): Cryptographic hashes catch byte-identical pages; SimHash catches near-duplicates (e.g., identical pages differing only by a session timestamp).
  • URL Seen (Bloom Filter + Disk KV): Store billions of visited normalized URLs compactly in a Bloom filter (false positives skip an extra crawl slightly; zero false negatives) backed by RocksDB.
  • Spider Trap & Endless Loop Defense: Cap maximum URL path depth/length (e.g., reject infinite calendar URLs like /cal/2026/12/01/next/next/...) and maintain a domain blocklist.

Share this article

Comments