Lesson 2 of 15
36. Design a Web Crawler

36.1 What do you ask first?

3 min read+10 XP

Step 1: Requirements (5 minutes)

LetterCandidate asksInterviewer answers
Scope"HTML only, or images and PDFs too? Do we re-crawl pages that change? Do we render JavaScript? Do we respect robots.txt?""HTML only for now. Yes, re-crawl, more often for pages that change. No JavaScript rendering. Yes, robots.txt."
Count"How many pages, how fast?""About a billion pages a month."
Access pattern"Is the web we crawl a few big sites or many small ones?""Millions of sites, from huge to tiny."
Latency"How fresh must the index be?""News sites within hours; most pages within weeks."
Exactness"Is missing some pages OK? Duplicates?""Missing a few is fine. Don't waste effort on duplicates."

Agreed requirements:

  • Functional (verbs): start from seed URLs; fetch pages; extract links; decide what to fetch next; store pages for the indexer; re-crawl by how often pages change.
  • Non-functional (adjectives): polite (respect robots.txt, never overload a site), scalable to a billion pages a month on many machines, resilient to bad sites (slow servers, traps, huge pages, malformed HTML), efficient (no duplicate URLs or content), prioritised (important and fresh pages first).

Interviewer pushback:

  • "Why is politeness a requirement and not a nice-to-have?" → A crawler fetching hundreds of pages a second can knock a small site over. Being impolite gets you blocked, harms site owners, and breaks the rules (robots.txt) the web runs on.

Memory code: "Ask how many pages, how fresh, and how gently."