System Design: Web Crawler (Walnut Crawl: URL Frontier, Politeness, robots.txt, URL-Seen Test, SimHash, Recrawl, Spider Traps)
We design a web crawler for a search engine and call it Walnut Crawl.
A crawler fetches a page, finds the links in it, and fetches those pages too. It stores every page for the search index, which another team builds.
The loop is simple. The hard part is that the web is too big to fetch, and every site is run by a person it can hurt.
A crawler must never hurt a small site or fetch one page twice by mistake. And it must not get lost in a site that makes endless addresses.
As in any system design interview, every number here is our own assumption for planning, and the design is our own.
All times are in US Pacific Time unless a line says otherwise. Story sites use the reserved .example names, so no real site is named.
How to read this post. It takes about 72 minutes in full, so it is built to be read in parts:
1. Requirements
1.1 What we are building
Walnut Crawl does four jobs:
- Find pages. Start from known addresses, follow links, and read the lists that sites publish of their own pages.
- Fetch politely. Fetch each site slowly enough that it never notices, and obey each site's robots.txt rules.
- Keep one copy. Know every address already seen, and notice when two addresses hold the same page.
- Stay fresh. Fetch important pages again often, and the rest less often, so the search index matches the live web.
The story. It is Tuesday 10 November 2026, a normal day for Walnut Crawl.
- 02:14. The server that runs one slice of our sites dies. Jessica Miller, our on-call engineer, is woken up. A standby server sends the next fetch 40 seconds later.
- 09:00. Grace Chen, web editor at Portland Daily News, publishes a story: the Burnside Bridge reopens. Five seconds later her site tells Walnut Crawl about it.
- 09:01. The page is fetched, stored and parsed, and the search index team hears about it.
- 10:30. Tom Becker's train forum in Columbus answers "too many requests". Walnut Crawl halves its speed there.
- 11:05. Tom's robots.txt file answers "server error" during a server move. Walnut Crawl stops fetching the forum until it can read the rules again.
- 11:47. Maria Lopez's bakery near the bridge in Portland gets its new menu fetched. Her site shares one server with about 40,000 other sites, so they share one speed limit.
- 14:20. Tulsa Tickets, a site built with JavaScript, returns an empty page. Walnut Crawl runs its JavaScript and finds 37 event links.
- Wed 11 Nov, 08:00. Luis Garcia's bike shop in Denver has made 2.1 million new addresses in a day, from its filter links. Walnut Crawl stops following them.
What happens to each person and site:
- Grace's article is in the search index about one minute after she publishes it.
- Tom's forum never gets more traffic than it asks for, even when its rules cannot be read.
- Maria's server holds 40,000 sites and gets at most 4 fetches a second from us in all.
- Tulsa Tickets gets found, even though its links appear only after JavaScript runs.
- Luis's shop loses no real product pages, and stops costing us millions of useless fetches.
- The dead server pauses 1 of 128 slices of the crawl for less than 2 minutes. Jessica only watches.
The hard part has four sides:
- The web is far bigger than any crawl, so choosing what to fetch next matters more than fetching fast.
- Every site has its own limit, and many small sites share one server.
- One page lives at many addresses, and some sites make endless addresses.
- Pages change all the time, so a crawl is never finished.
1.2 Words we use
The web:
| Word | Meaning here |
|---|---|
| URL | The address of one page, such as https://news.portlanddaily.example/2026/11/10/burnside-bridge-reopens |
| Host | The name part of a URL, such as news.portlanddaily.example |
| Registered domain | The name a person or company registers, such as portlanddaily.example. It can have many hosts |
| Page | What a URL returns: here, an HTML document |
| Link | A URL found inside a page |
| Fetch | One HTTP request by Walnut Crawl for one URL |
| Status code | The number a server sends back: 200 OK, 304 not modified, 404 not found, 429 too many requests, 503 unavailable |
| robots.txt | A file at the root of a host that says which paths crawlers may fetch |
| Sitemap | A file in which a site lists its own URLs |
| IndexNow | A way for a site to tell crawlers at once that a URL changed |
Our crawl:
| Word | Meaning here |
|---|---|
| Frontier | The URLs waiting to be fetched, in the order we want them |
| Politeness | Fetching slowly enough that no site is hurt |
| Rate | How many fetches a second we allow a host |
| Gap | The least wait between two fetches to one host: one second divided by the rate |
| Priority band | One of four lists of waiting URLs, from urgent to low |
| Token | Permission for one fetch to a server that many sites share |
| Seen test | The check of whether a URL is already known |
| Normalize | Rewrite a URL into one standard spelling, so two spellings of one address become one URL |
| Recrawl | Fetching a known page again to see if it changed |
| Tier | One of four groups of pages, 0 to 3, with the same importance and the same range of times between fetches. Tier 1 is the top 100 million pages |
| Host budget | How many fetches a host may get in one day |
| Version tag | A short string a site sends with a page. It changes when the page changes |
| Spider trap | A site that makes endless URLs, so a crawler keeps finding pages that add nothing |
| Render | Run a page's JavaScript and keep the HTML it builds |
Our servers:
| Word | Meaning here |
|---|---|
| Partition | One of 128 slices of all hosts, chosen by a hash of the host name |
| Owner | The one server that decides every fetch for one partition |
| Standby | A copy of an owner in another zone, ready to take over |
| Region | One of our two groups of data centers: West in Oregon, and East in Virginia |
| Zone | One building or group of buildings inside a region, with its own power |
| Lease | A claim that ends by itself after a set time unless it is renewed |
| Epoch | A number that goes up by one each time a new owner takes over. Writes with an older epoch are refused |
| WARC file | A standard archive file of web pages: each fetch is one record in it |
IDs in the story:
| ID | What it names | Example from the story |
|---|---|---|
| p-041 | A partition | The slice that holds news.portlanddaily.example |
| p-093 | A partition | The slice that holds Maria's bakery |
| own-west-c-11 | An owner server | The standby that took over p-041 at 02:14 |
| f-041-0918273 | A fetch ID. Its first number is the partition | The first fetch of Grace's article |
| 52e1:9f3a | A URL key, shortened | Host hash, then URL hash, of Grace's article |
1.3 Every kind of request and change
Each kind comes in at a different rate and is handled by different parts. Every row is covered by a stage or a deep dive.
| Kind | What it is | How big or how often | Part that handles it | Outside company that takes part |
|---|---|---|---|---|
| Seed | An operator adds a URL to start from | thousands a day | Crawl API, Discovery intake | none |
| Host policy | An operator caps, blocks or unblocks a host | a few a day | Crawl API, Control store, owners | none |
| Link | A URL found in a fetched page | 486,000 a second | Link router, owners | none |
| Sitemap | A site's list of its own URLs | read daily or weekly per host | Discovery intake | none |
| IndexNow ping | A site says a URL changed | thousands a second | Discovery intake | none |
| Fetch | One HTTP request for one URL | 1 billion a day | Owners, Fetchers | the site's own server |
| robots.txt | A host's rules, fetched again each day | about 580 a second | Owners, Fetchers | the site's own server |
| DNS lookup | A host name turned into an IP address | 1,000 to 2,000 a second | DNS resolver | the site's name servers |
| Store | A fetched page written to a file | 700 million new bodies a day | Fetchers, Page store | none |
| Parse | Links and text taken out of a page | 700 million a day | Parsers | none |
| Render | A JavaScript page run in a browser | 35 million a day | Renderers | none |
| Page changed | A note to the search index team | about 700 million a day | Event stream | none |
| Takedown | An operator removes a page | a few a day | Crawl API, Control store, owners | none |
1.4 Functional requirements
- Discover. Take seeds, sitemaps and IndexNow pings, and find new URLs in the links of every page.
- Fetch politely. Fetch HTML pages over HTTP and HTTPS, within each host's rate and each shared server's limit.
- Obey robots.txt. Read each host's rules before its pages, and never use rules more than 24 hours old.
- Store. Keep every fetched page for 90 days and tell the search index team when a page changed.
- Extract. Take the links and text out of every new page.
- Find copies. Notice exact copies and near copies of pages.
- Recrawl. Fetch pages again by importance and by how often they change.
- Avoid traps. Stop following sites that make endless URLs.
- Render. Run the JavaScript of pages whose links appear only after it runs.
- Operate. Let our crawl engineers add seeds, block hosts, cap rates and take pages down.
Out of scope: building the search index and ranking, and pages behind logins or forms. So are images, video, and keeping pages beyond 90 days.
1.5 Non-functional requirements
- Polite. One owner decides every fetch to a host, always within the host's rate and connection limit.
- Throughput. 1 billion fetches a day on average, and room for 20,000 fetches a second in each region.
- No lost URL. The seen test never calls a new URL "seen". A server crash loses no logged link.
- Fresh. 99% of tier-1 pages fetched again within 2 days, and every indexed page within 60 days. A host with more pages than its rate can fetch in 60 days is the one exception, as Kevin's docs site shows in the bottlenecks.
- Fast for pushed pages. A URL sent by IndexNow is stored within 15 minutes at p90. So 90 of every 100 pushed URLs are stored within it, when the host's rate allows.
- Stored means safe. A page counts as stored only when its record is in a WARC file in the Page store.
- Safe fetches. No fetch to a private or internal network address. Every fetch stops at 2 MB of HTML and 30 seconds. Sitemap files are the one exception: they may be up to 50 MB.
- Recovery. Losing an owner pauses its partition for about 2 minutes.
1.6 The numbers
A crawler sets its own load: nobody can send it a rush. So the room above the average is for catching up after an outage, not for spikes.
| Number | How we get it | Result | What it decides |
|---|---|---|---|
| Fetches | 1 billion a day ÷ 86,400 seconds | About 11,600 a second | The average we plan for |
| Spare capacity | Each region is sized for 20,000 a second: 20,000 ÷ 11,600 | 1.7 times the whole average, in each region | Normally each region runs 64 of the 128 partitions. After a region is lost, the other runs all 128 |
| The day's mix | 250 million first fetches + 678 million recrawls + 20 million retries + 50 million robots.txt files + 2 million sitemap files = 1 billion. Of the 948 million page fetches, 75 million answer "not modified" and 173 million send the same bytes | 925 million downloads, 700 million new bodies | Unchanged pages must cost almost nothing to store |
| Backlog | 1 billion new URLs found a day, minus 250 million first fetches | 750 million new URLs a day never fetched | Most have low scores. A URL not fetched within 90 days is dropped |
| Bytes in | 925 million × 45 KB = 41.6 TB a day × 8 ÷ 86,400 | About 3.9 Gbit/s; 6.7 Gbit/s at 20,000 a second | Bandwidth is small. The limits are the hosts' rates, DNS and the seen test |
| Stored | 700 million new bodies × 45 KB = 31.5 TB a day × 90 days | About 2.8 PB per copy | Pages go to object storage, in large files |
| Links | 700 million new bodies × 60 links = 42 billion a day ÷ 86,400 | About 486,000 a second | The seen test is the busiest part of the crawl |
| Known URLs | About 1 new URL found per fetched page, 1 billion a day, kept for 90 days, under our cap of 100 billion. Each key is 16 bytes: 100 billion × 16 bytes | 1.6 TB of keys, 12.5 GB per partition | The keys fit on each owner's local disk; no remote database per link |
| Hosts | 200 million known; 50 million fetched in a day | About 580 robots.txt fetches a second | One robots.txt fetch per host a day |
| DNS lookups | 50 million hosts a day, each looked up 2 to 3 times a day as its cached answer ends | About 1,000 to 2,000 a second | Our own resolvers with a cache |
| Connections | 20,000 fetches a second × about 1 second each | About 20,000 open connections at the peak | Each Fetcher holds many slow connections at once |
| Per partition | 20,000 a second ÷ 128 partitions | About 156 fetches a second | One owner server can decide every fetch of its slice |
| Freshness | 10 billion indexed pages ÷ 678 million recrawls a day | Every page about every 15 days | Important pages come back far more often, the rest less |
| Renders | 700 million new bodies × 5% need JavaScript | 35 million a day, about 405 a second | A separate lane, so slow renders never hold up normal pages |
| Render file fetches | 35 million renders × 30 files × 20% not in the proxy's cache | 210 million a day, about 2,400 a second | Counted apart from the 1 billion. Each still waits for its host's turn |
What these numbers tell us. Fetching is not the hard part: 6.7 Gbit/s fits on a few network cards. The hard parts are elsewhere:
- each host's polite rate, which no amount of servers can raise;
- the seen test, at 486,000 links a second against up to 100 billion URLs;
- choosing which 678 million of 10 billion pages to fetch again each day.