AlgoViz

Design a URL crawler

hard 60 min

Start from a few addresses, download pages, find links, and repeat a billion times a month.

Numbers that decide

Work out a number when the answer changes what you build.

Capacity

Scale estimates

Pages

1B30×86,400≈386 pages/s3×≈1,157 at peak\frac{1\text{B}}{30 \times 86{,}400} \approx 386\ \text{pages/s} \qquad 3\times \approx 1{,}157\ \text{at peak}
Decision: modest. Size for a thousand fetches a second.

Hosts

1,157 pages/s÷1 per host=1,157 hosts ready10M pages86,400 per day≈116 days1{,}157\ \text{pages/s} \div 1\ \text{per host} = 1{,}157\ \text{hosts ready} \qquad \frac{10\text{M pages}}{86{,}400\ \text{per day}} \approx 116\ \text{days}
Decision: keep thousands of hosts ready, and give large sites a budget instead of hope.

Links

386×80≈30,900 checks/s×5%≈1,540 new/s=4B a month386 \times 80 \approx 30{,}900\ \text{checks/s} \qquad \times 5\% \approx 1{,}540\ \text{new/s} = 4\text{B a month}
Assumes 80 links a page and 95% already seen. Peak is 92,600 checks a second. Decision: an in-memory set, and a frontier that may say no.

All numbers, each with its decision

QuantityWorkingDecision
Download386 × 100 KB = 38.6 MB/s = 309 Mb/s; 926 Mb/s at peakOne network card could do it; we use several machines for failures
Raw bytes1B × 100 KB = 100 TB a monthCompress before storing
Stored÷ 8 = 12.5 TB a month, 150 TB a yearObject storage
URL records10B × 300 B = 3 TB, 9 TB on three copiesA partitioned store
Seen set10B × 14.4 bits = 18 GBFits in memory, 1.8 GB on each of 10 shards
Exact 8-byte hashes10B × 8 B = 80 GBPossible too: 8 GB a shard
Hot frontier100M × 70 B = 7 GBMemory for the next hours, disk for the rest
SimHash10B × 8 B = 80 GB, 1.3 TB in 16 tablesOnly if near copies matter
robots and DNS10M hosts × about 300 B = 3 GBKeep with the host's owner
Assumptions: 100 KB of HTML, 8 times compression, 100-byte URLs, 10 billion known URLs. Link discovery alone would reach that in 2.5 months, so we also plan what to forget.

Machines

How many connections?

Little's law, with and without timeouts

1,157×0.35 s≈4051,157×(0.35+1%×30 s)≈7521{,}157 \times 0.35\ \text{s} \approx 405 \qquad 1{,}157 \times (0.35 + 1\% \times 30\ \text{s}) \approx 752
One fetch in a hundred that hangs for 30 seconds nearly doubles the open connections. Assumed times: median 200 ms, p90 500 ms, p99 2 s, average 350 ms. Decision: short timeouts, and a limit on slow answers.
PartWorkingResult
Fetchers752 connections, about 1,000 on one asynchronous processOne is enough; run 8 in 4 zones
Parsing386 × 50 ms = 19 cores; 58 at peakSix machines of 16 cores, with room
Frontier30,900 to 92,600 checks and 1,157 leases a second10 shards; memory, not CPU, decides
DNS386 × 5% misses = 19 lookups a secondOne local resolver and a spare
Waiting workA 10 minute storage stall at peak: 1,157 × 600 × 12.5 KB = 8.7 GBKafka holds it easily
Assumes a 95% DNS hit rate and 50 ms of CPU to parse a page. Both are the first things to measure.

Money

Small objects are the expensive part

ItemWorkingA month
One object for each page1B PUT × $0.005 per 1,000$5,000
Packed, 1 GB files12,500 PUT6 cents
150 TB, Standard50 TB × 23+100TB×23 + 100 TB × 22$3,350 after a year
150 TB, infrequent access150,000 GB × $0.0125$1,875 plus reading fees
12.5 KB objects thereBilled as 128 KB each10 times the bytes
AWS list prices for S3 in us-east-1, November 2026. The store already keeps several copies, so do not multiply by three again.

What if

Change one number

IfThen
1 million pages a month0.4 pages a second: version 1 is the answer
All pages from one host86,400 a day, whatever we buy
Half are returns and 60% answer 30430% fewer pages to download
Every page rendered, 2 CPU seconds each772 cores on average, 2,300 at peak: compute is now the limit
100 billion pages a month38,600/s; a seen set for 1 trillion URLs is 1.8 TB, so filters split by host and exact sets on disk
TrillionsRegions coordinate only through summaries, near-copy search uses locality-sensitive hashing, most URLs are never queued