System design interview: design a web crawler

A web crawler starts from a set of seed URLs, downloads each page, pulls out the links and adds the new ones to a queue called the URL frontier. The interview is about four things: how the frontier decides what to fetch next, how you stay polite to each website, how you avoid fetching the same page or content twice, and how a crawl of billions of pages survives machines failing halfway through.

By Published 7 min read

1. Clarify the requirements

"Design a web crawler" can mean a search engine's crawler, a price monitor for a few thousand shops, or a one-off archive job. Each has a different answer, so ask what the crawl is for before you draw anything.

  • Purpose: feeding a search index (breadth, freshness) or a narrow job such as monitoring competitors (depth on a few sites)?
  • Content types: HTML only, or also PDFs, images and pages that need JavaScript to render?
  • Scale and freshness: how many pages, and how often must a page be re-crawled? News sites change hourly, most pages rarely.
  • Constraints: must obey robots.txt and keep the load on any single site low. Assume both even if the interviewer does not mention them.
  • Out of scope unless asked: ranking, the search index itself, and logging in to sites.

2. Estimate the scale

State round numbers as assumptions. These are illustrative figures for a large general-purpose crawler, not any real search engine's.

Back-of-envelope estimate for a web-scale crawler (assumed figures)
QuantityAssumptionResult
Pages per month1 billionabout 385 pages a second on average, plan for 2x at peak
Average page size100 KB of HTMLabout 100 TB of raw HTML a month
Five years of storagekeep raw pages, compressed about 4xroughly 1.5 PB
URLs discoveredabout 30 new links per pagethe frontier grows far faster than you can fetch, so it must prioritize
Distinct hoststens of millionspoliteness state (last fetch time, robots rules) must be sharded too
Back-of-envelope estimate for a web-scale crawler (assumed figures). Scroll sideways on a small screen.

The numbers tell you two things. Throughput per machine is not the issue; a few dozen fetcher machines can sustain 800 pages a second. The frontier is the issue: it holds billions of URLs, most of which you will never fetch, so it needs disk-backed storage and a way to choose.

3. The crawl loop

  1. Input
    • Seed URLs
    • Re-crawl scheduler
  2. Frontier
    • Priority queues
    • Per-host queues
    • Host heap (next allowed time)
  3. Fetch
    • Fetcher workers
    • DNS cache
    • robots.txt cache
  4. Process
    • Parser and link extractor
    • Content fingerprint check
    • URL normalizer and seen-set
  5. Storage
    • Raw page store
    • Metadata DB
    • Frontier checkpoints
High-level crawler architecture. Seed URLs enter the URL frontier. Fetcher workers take URLs from the frontier, check robots rules and a DNS cache, and download pages. Downloaded pages go to a parser that extracts text and links and computes a content fingerprint. The content store keeps the page if it is new. Extracted links are normalized, filtered against the URL-seen set, and sent back into the frontier.
  1. PickA fetcher asks the frontier for the next URL whose host is allowed to be contacted now.
  2. Resolve and checkResolve the host through a local DNS cache (DNS lookups are slow and are a classic hidden bottleneck), and check the cached robots.txt rules for that path.
  3. FetchDownload with a timeout and a size cap, follow a limited number of redirects, and record the status code, headers and fetch time.
  4. ParseExtract links and text. Compute a fingerprint of the content to detect duplicates.
  5. StoreWrite the page to blob storage and its metadata (URL, fingerprint, last fetched, status) to a database.
  6. Feed backNormalize each extracted link, drop the ones already seen, and push the rest into the frontier with a priority.

4. The URL frontier, the core of the design

A single FIFO queue fails in two ways. It fetches unimportant pages as readily as important ones, and because pages link heavily within their own site, it sends bursts of requests to one host. The standard fix, described in the Mercator crawler paper, splits the frontier into two layers.

  • Front queues (priority). A prioritizer gives each URL a score: how important the site is, how often the page changes, how deep it is from the home page. URLs go into one of several queues by score, and a selector drains high-priority queues more often.
  • Back queues (politeness). Each back queue holds URLs for exactly one host. A heap ordered by "earliest time this host may be contacted again" tells fetchers which queue to take from next. After each fetch, that host's next allowed time moves forward by the crawl delay.
  • Disk, not memory. Billions of URLs do not fit in RAM. Keep the head of each queue in memory and the rest in an append-only log or a key-value store, loaded in batches.
next_allowed[host] = last_fetch_finished[host] + max(robots_crawl_delay, k * last_response_time)

# k around 10: if a server took 300 ms to answer, wait about 3 s before
# the next request to it. Slow servers get crawled more gently.
Politeness in one rule

5. Deduplication: URLs and content

Duplicates waste most of a naive crawler's budget. Handle them at two levels.

Two kinds of duplicates and how to catch them
ProblemExampleTechnique
Same URL written differentlyHTTP://Example.com:80/a/../b?utm_source=xNormalize: lowercase scheme and host, drop default ports, resolve dot segments, strip tracking parameters and fragments, then check a URL-seen set
URL-seen set too big for memoryTens of billions of URLsA Bloom filter in front of a sharded on-disk set: false positives skip a few new URLs, which is acceptable; false negatives cannot happen
Different URLs, identical pageMirrors, session IDs in URLs, print versionsHash the normalized content (exact duplicates) and store the hash per page
Different URLs, nearly identical pageSame article with a different ad or dateSimHash or MinHash fingerprints; pages within a few bits are treated as duplicates
Two kinds of duplicates and how to catch them. Scroll sideways on a small screen.

6. Scaling out

  • Partition by host. Hash the host name to pick the node that owns it. That node holds the host's back queue, politeness timer and robots cache, so no cross-node locking is needed. Links to other hosts are forwarded to their owners in batches.
  • Fetchers are stateless. They can be added or removed freely; they only need the frontier node to hand them work.
  • Storage splits by access pattern. Raw pages go to cheap blob storage; per-URL metadata (last fetched, fingerprint, status) goes to a wide-column or key-value store keyed by URL hash.
  • Geography. Crawling a site from a data center near it cuts latency, so large crawlers run fetchers in several regions and route hosts accordingly.

7. Freshness and re-crawling

A crawler never finishes; it revisits. Track how often each page actually changed (compare fingerprints across fetches) and schedule the next visit by that rate: a front page that changes hourly is revisited hourly, an archive page monthly. Conditional requests with If-Modified-Since or an ETag let servers answer "not modified" cheaply. Sitemaps and push protocols such as IndexNow tell you directly which URLs changed, which is far cheaper than guessing.

8. Failure modes

What breaks and how the design copes
FailureEffectMitigation
Frontier node crashesIts hosts stop being crawled; in-memory queue heads are lostCheckpoint queues to durable storage every few minutes; reassign the host range to another node and replay from the checkpoint
Fetcher dies mid-downloadA URL is taken but never finishedLease URLs with a timeout; an unacknowledged lease returns to the queue
A site slows down or returns 5xxRequests pile up against itBack off exponentially for that host, using the adaptive delay above
DNS resolver overloadedEvery fetch stallsLocal caching resolvers per fetcher pool, asynchronous lookups
Spam and link farmsBudget spent on worthless pagesLower the priority of hosts with low-quality signals; cap pages per host
What breaks and how the design copes. Scroll sideways on a small screen.

9. Trade-offs to discuss

  • Breadth-first or best-first. Breadth-first is simple and finds many sites; best-first by importance gets valuable pages sooner. Real crawlers use priorities, with breadth as a tie-breaker.
  • Render JavaScript or not. A headless browser sees content that plain HTML fetching misses, but costs ten to a hundred times more per page. Render only the hosts that need it.
  • Exact or approximate seen-set. A Bloom filter is small and fast but occasionally skips a new URL. For a search crawler that is fine; for a compliance archive it may not be.
  • Store everything or only changes. Keeping every version supports history and diffing, at a large storage cost.

10. How to talk through it in the interview

Fictional example

Moving from the loop to the hard part
Candidate
That is the basic loop: frontier, fetch, parse, back to the frontier. If I stop there, the crawler would send hundreds of requests a second to whichever site links to itself the most.
Interviewer
So how do you prevent that?
Candidate
I would split the frontier in two. Priority queues decide what matters, and per-host queues with a heap of next-allowed times decide when each site can be hit again. Then I will cover duplicates and what happens when a frontier node dies.
  • Draw the loop first, then spend most of the time on the frontier.
  • Mention robots.txt and politeness without being asked; it signals real-world awareness.
  • Have a concrete answer for traps and for crash recovery: they are the usual follow-ups.

Rehearsing the crawler question out loud

System design is a spoken exercise, so practice it that way. Have a friend read the prompt on a video call, or record yourself answering it. Natively transcribes the session live and can sketch the architecture as a diagram while you talk, so afterwards you can check whether you actually explained the frontier's two layers or only drew boxes. The saved transcript shows where you spent your minutes; most candidates find they spend too long on the fetch step and too little on duplicates.

For the neighbouring questions, the rate limiter uses the same per-key timing idea as crawl politeness, and the job scheduler covers leases and retries in more depth. For a design where the hard part is contention rather than breadth, try the ticket booking system.

Questions people ask

What is the URL frontier in a web crawler?

It is the queue of URLs waiting to be fetched. Large crawlers split it into priority queues, which decide what matters most, and per-host queues with a timer, which make sure no single website is contacted too often.

How does a web crawler avoid duplicate pages?

It normalizes URLs and checks them against a seen-set (often a Bloom filter backed by disk), and it fingerprints page content with a hash or SimHash so different URLs serving the same page are stored once.

How do crawlers stay polite to websites?

They obey robots.txt, keep one queue per host, and wait between requests to the same host, often longer when the server responds slowly. They also back off on errors.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP