interviewmind

Design a web crawler

“Design a web crawler” is a system design interview question. Design a web crawler that feeds a search index. Starting from a list of seed URLs, it downloads each page, pulls out its links, and adds the new ones to the list to crawl. It should fetch 1 billion pages a month, about 400 a second, averaging 100 KB a page. It must follow each site’s robots.txt, send any one site no more than one request a second, skip pages it already has, and revisit pages that change often more often than ones that don’t. Below is what to cover and 3 hints; press Practice and Dana, the interviewer, asks it out loud while you sketch the design.

Updated · By InterviewMind

Practice this question

Free in your browser, no account.

The problem

System design

Design a web crawler that feeds a search index. Starting from a list of seed URLs, it downloads each page, pulls out its links, and adds the new ones to the list to crawl.

It should fetch 1 billion pages a month, about 400 a second, averaging 100 KB a page. It must follow each site’s robots.txt, send any one site no more than one request a second, skip pages it already has, and revisit pages that change often more often than ones that don’t.

Things to cover

  • The URL frontier: what to fetch, and in what order
  • Politeness: robots.txt and a rate limit per site
  • Spotting duplicate URLs and duplicate content
  • Spreading the work across machines, and crawler traps

Hints

Open one at a time, and try the question again after each.

Hint 1

Start with storage and bandwidth: a billion pages at 100 KB each is 100 TB a month, and 400 pages a second is about 40 MB a second, around 320 megabits, arriving all day.

Hint 2

The core is the URL frontier: a priority queue that decides what’s worth fetching, feeding one queue per site, so each site is fetched by one worker at its own polite pace.

Hint 3

The hard parts are duplicates and traps. Keep a fast set of URLs already seen, such as a Bloom filter, hash page content to catch copies under different URLs, and cap the depth per site so endless calendars and generated links can’t hold the crawler forever.

Practice it out loud

In the practice room Dana reads the question aloud in your browser’s own voice, with captions, and you answer in the editor beside it, in a design doc with the requirements filled in and a section for each part. It’s free and needs no account. Run the InterviewMind desktop app beside it and it hears the question the way it hears a real call, so you can see what it would show you in the live round.

Practice this question

More system design questions

interviewmind

Clarity under pressure.

Download for macOSWindows

On an Intel Mac? Download for Intel