Resilience & Service Patterns • Web Crawler DesignMedium⏱️ ~2 min
Deduplication Strategies: URL Normalization and Content Fingerprinting
Deduplication happens in two planes and is critical for efficiency at scale. The open web contains 20% to 40% content level duplicates, meaning without dedup you waste nearly half your storage and indexing capacity. URL level dedup prevents re queuing the same normalized URL, while content level dedup avoids storing or indexing near identical pages even when URLs differ.
URL normalization is surprisingly complex. You must canonicalize trailing slashes, case sensitivity, query parameter ordering, and tracking parameters (utm_ parameters). Failures here cause re fetch storms: the same logical page with different URL variants gets crawled repeatedly. Content level dedup uses lightweight fingerprints like 64 bit SimHash. SimHash computes a hash where similar documents have similar hashes, measurable by Hamming distance. Google published results showing detection across 8 billion plus pages using 64 bit signatures, with Hamming distance thresholds of 3 to 4 bits identifying near duplicates.
The implementation uses layered structures for memory efficiency. Each crawler agent maintains small in memory Bloom filters (1% false positive rate) for hot URL sets, plus a sharded exact set in durable storage. For content, compute SimHash on extracted text and store in a locality sensitive hashing (LSH) index that clusters similar hashes. This allows sub linear lookup: you do not compare every new page against all previous pages.
Trade off: aggressive near duplicate filtering (low Hamming thresholds) saves storage but risks dropping meaningful variants like localized pages or paginated results with similar templates. Looser thresholds (Hamming distance 5 to 6) increase storage by 10% to 20% but improve recall for legitimate content variations. Production systems whitelist known template differences and tune thresholds per domain category.
💡 Key Takeaways
•Two level deduplication: URL level uses Bloom filters (1% false positive) plus exact sharded sets, content level uses 64 bit SimHash with Hamming distance thresholds of 3 to 4
•Open web contains 20% to 40% content duplicates; effective dedup reclaims similar magnitude of storage and indexing input/output (IO), saving 30% to 40% infrastructure cost
•SimHash scales to billions: Google demonstrated near duplicate detection across 8 billion plus pages using 64 bit signatures with locality sensitive hashing for sub linear lookups
•URL normalization failures cause re fetch storms: same page with trailing slash differences or utm parameter variants gets crawled repeatedly, multiplying bandwidth costs
•Trade off between strictness and recall: Hamming distance threshold 3 to 4 is aggressive (high precision, some false positives drop valid variants), 5 to 6 looser (better recall, 10% to 20% more storage)
•Whitelist template differences: localized pages, paginated results, and dynamic content need domain specific rules to avoid over suppression of legitimate variations
📌 Examples
URL normalization handles: example.com/page?b=2&a=1 and example.com/page?a=1&b=2 (parameter order), example.com/Page vs example.com/page (case), example.com/page/ vs example.com/page (trailing slash)
SimHash computation: extract text shingles (word n grams), hash each shingle, weight by term frequency, produce 64 bit fingerprint where bit i is set based on weighted voting of shingle hashes
Common Crawl uses layered dedup: in memory Bloom filters per worker node for recent URLs, plus distributed exact set in key value store, achieving 99% dedup accuracy with under 10 gigabytes (GB) memory per billion URLs