Back to sketch

SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 14

Design a web crawler

Advanced · 45 min · Distributed infrastructure

A search team needs fresh copies of public web pages to build an index. Starting from a seed list, the crawler fetches pages, follows links to find more, and comes back later to pick up changes, without ever hammering a website or ignoring its crawling rules.

Requirements

  • Starting from seed URLs, fetch HTML pages, extract links, and discover new URLs.
  • Obey robots.txt and never send more than one request per second to a host unless its robots.txt allows more.
  • Store each fetched page with its URL, fetch time, and HTTP metadata for the indexing team.
  • Recrawl known pages on a schedule that reflects how often they change.

Constraints and assumptions

  • Target 1 billion page fetches a month, with peaks around 1,000 fetches per second.
  • Average page 100 KB of HTML; about 10 million distinct hosts; 1 million seed URLs.
  • Roughly 30% of fetched pages are exact or near duplicates of pages already stored.
  • Some pages (news front pages) change hourly; most change less than once a month.
  • Each discovered page links to about 50 URLs, most already known.

Out of scope for the first sketch

Rendering JavaScript-heavy pages · Building the search index and ranking · Images, video and other non-HTML content

Draw your design

Rough math and notes

Done on paper? Compare with the worked approaches