Mục tiêu: tải hàng tỉ trang, mới hóa định kỳ, không sập server bị crawl.
Vòng lặp & thành phần:
1. URL Frontier: hàng đợi URL chờ crawl — không chỉ là queue thường mà còn lo ưu tiên (PageRank/độ mới) và politeness (giãn nhịp mỗi host).
2. Fetcher: tải HTML (worker phân tán), tuân robots.txt + rate-limit per-domain.
3. Parser: trích link mới + nội dung.
4. URL dedup: kiểm tra URL/nội dung đã thấy chưa.
5. Content store + index downstream.
Tránh crawl trùng:
- URL seen: chuẩn hóa URL (bỏ fragment, sort query) rồi tra Bloom filter / hash set — tránh đưa lại URL đã có.
- Content dedup: nhiều URL trỏ cùng nội dung → so checksum/SimHash để bỏ trang trùng nội dung (mirror).
Politeness (chơi đẹp):
- Tôn trọng robots.txt và Crawl-delay.
- Giới hạn đồng thời theo host (vd 1 request/host/giây) → frontier nhóm URL theo host, mỗi host một sub-queue có lịch.
- Đặt User-Agent rõ ràng, hỗ trợ backoff khi server trả 429/503.
Lưu ý:
- Bẫy: spider trap (URL vô hạn từ calendar), trang động JS-render → cần headless cho một phần.
- Phân tán bằng consistent hashing theo domain để cùng host về cùng worker (giữ politeness + cache DNS).
Goal: download billions of pages, refresh periodically, without overwhelming crawled servers.
Loop & components:
1. URL Frontier: the queue of URLs to crawl — more than a plain queue; it handles prioritization (PageRank/freshness) and politeness (per-host pacing).
2. Fetcher: downloads HTML (distributed workers), obeys robots.txt + per-domain rate limits.
3. Parser: extracts new links + content.
4. URL dedup: checks if a URL/content was already seen.
5. Content store + downstream index.
Avoid duplicate crawling:
- URL seen: normalize URLs (drop fragments, sort query) then check a Bloom filter / hash set — avoid re-enqueuing known URLs.
- Content dedup: many URLs map to identical content → compare checksum/SimHash to drop mirrors.
Politeness:
- Respect robots.txt and Crawl-delay.
- Limit per-host concurrency (e.g. 1 req/host/sec) → the frontier groups URLs by host, each with a scheduled sub-queue.
- Set a clear User-Agent, back off on 429/503.
Notes:
- Traps: spider traps (infinite calendar URLs), JS-rendered pages → need partial headless rendering.
- Distribute via consistent hashing by domain so the same host hits the same worker (preserves politeness + DNS cache).