Skip to content
derpx06.dev
WritingExplainersNotesAbout
works on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisationworks on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisation

Learning in public.

A student's notebook on system design, distributed systems and databases. Shared as I learn.

ReadWritingExplainersNotesAbout
ElsewhereGitHubLinkedInHugging FaceLeetCode
Say hellomanaskhairnar1511@gmail.com
derpx06
NORMALmain© 2026 Derpx06Pune, Indiatop ↑
Blog/System Design

How does a search engine find one page out of billions so fast?

Google does not search the web when you do. It built a cheat sheet first. Here is how that list works, how pages get ranked, and how it scales.

Derpx066 Oct · 5 min read
Contents
Why can't it just scan every page?How does it get the pages?What is an inverted index?How does "pizza recipe" work?Which page goes on top?What breaks when the web is huge?Your turnSources
0% read · 5 min leftBack to top ↑
On this page0%
Contents
Why can't it just scan every page?How does it get the pages?What is an inverted index?How does "pizza recipe" work?Which page goes on top?What breaks when the web is huge?Your turnSources

You type "pizza near me" and get answers before you blink. The web has billions of pages, and no computer reads them all while you wait.

So what is it doing? It doesn't search the web when you search. It searched days ago and wrote a cheat sheet. Your query only reads the cheat sheet. Let's build one from a tiny version.

Why can't it just scan every page?

You have 5 pages and want the ones containing "pizza". Open each, look for the word. Done in a blink.

Now make it a billion pages. That would be like re-reading a whole library every time someone asks one question.

Scan everythingSearch time: open every page and scan it.
→
Cheat sheetSearch time: look up the word in a prebuilt list.

Click through the journey once, from web page to your screen.

Crawlers
Inverted index
Ranking
Your results

Crawlers fetch pages and follow their links

Step 1 of 5
Most of the work happens before you type anything.

Notice that you only show up at step 3. The rest was already done. The next question: where do the pages come from?

How does it get the pages?

Programs called crawlers fetch a page and pull out its links. Then they fetch those pages too, and so on, forever. It is like following a link, then the links on that page, then the links on the next one.

The 1998 Google paper (Brin and Page) ran about 3 crawlers, each with roughly 300 connections open at once. At peak they pulled over 100 pages a second. Looking up website addresses (DNS) was a big slow part, so each crawler kept its own memory of them.

Quick estimate, not a paper number

The paper reports it took roughly 9 days to download 26 million pages. At a steady 100 pages a second, 26,000,000 / 100 = 260,000 seconds, about 3 days. Real life was slower than the peak, which is normal.

Pages are on disk now. How do we find "pizza" in them fast?

What is an inverted index?

A normal book index maps a page to its words. Flip it: map each word to the pages that contain it. That's an inverted index.

WordPages that contain it
pizza2, 7, 9
recipe1, 7, 12
oven3, 9

The paper calls the per-word list a doclist: all the documents a word appears in, plus where. Keeping each list sorted is the secret, and you'll see why now.

How does "pizza recipe" work?

You want pages with both words. Walk down the two lists together, like comparing two sorted lists of numbers.

  1. pizza: 2, 7, 9. recipe: 1, 7, 12.
  2. Look at the front of each list: 2 and 1. 1 is smaller, so move that list forward.
  3. Keep moving whichever side has the smaller number.
  4. When both sides show 7, that's a match. Page 7 has both words.

You never go back. So the work depends on the length of the two lists, not the size of the web. The paper keeps lists sorted by document ID for this reason. It allows "quick merging" of lists for multi-word queries.

But thousands of pages may match. Which goes first?

Which page goes on top?

Order matters more than the match. The engine needs a way to tell a good page from a spammy one.

Brin and Page's idea is PageRank: a link is a vote, and votes from important pages count more. Picture a "random surfer" who keeps clicking links and sometimes gets bored and jumps to a random page. The more often they would land on a page, the higher its rank.

Think of it like this

A recommendation from a well-respected expert counts for more than one from a stranger. Links to a page work the same way.

The paper's formula uses a damping factor d, usually 0.85. That is the chance the surfer keeps clicking instead of jumping away. The paper reports that PageRank for 26 million pages could be computed in a few hours on a medium-size workstation.

The final rank also uses where the word appears (title, anchor text, nearness of words) plus PageRank. Anchor text is the clickable words of a link. The paper uses it to describe the page the link points to.

That works on a laptop. What breaks at web scale?

What breaks when the web is huge?

The paper is blunt: a disk seek takes about 10 ms, so the design avoids seeks wherever it can. Here's the map from "works on a laptop" to "works for everyone".

BottleneckStandard fix
Too many pages for one diskSplit the index across many machines (a shard each)
Too many searches at onceKeep copies (replicas) of each shard
Popular searches repeatCache the answers
Disk is slowKeep hot parts in memory

The paper itself splits its inverted index into 64 "barrels", each holding a range of words. It also keeps a small set of lists for title and anchor hits. It checks those first, and only checks the bigger lists if there aren't enough matches. Google's own docs state that today's index is hosted on thousands of computers, but they don't explain how it's split.

That diagram is the general sharding idea, not a claim about one company's setup. Each shard answers for its own slice, then the best results get merged.

Your turn

  • You have 10 million pages and one laptop. What fits in memory, and what stays on disk?
  • Your index is sharded by page. A search must ask every shard. What does that cost you when one shard is slow?
  • A new page appears. Do you rebuild the whole index, or add it somewhere small first?
Key takeaways
  • A search engine searches a prebuilt inverted index, not the live web.
  • Sorted lists per word make multi-word searches a quick walk, not a scan.
  • PageRank turns links into votes so the best matches go first.
  • To scale: shard the index, replicate shards, cache popular answers.

Sources

  • Brin, Page, The Anatomy of a Large-Scale Hypertextual Web Search Engine, Computer Networks and ISDN Systems, 1998
  • Google Search Central, How Google Search works
ShareXLinkedInEmail
Written by Derpx06A developer who builds AI search tools and the code around them. I explain what I got wrong first, so you can skip it. Spotted a mistake? Tell me — corrections get credited.
System Design · 4 minHow does video streaming work? (Why movies play on slow Wi-Fi)System Design · 5 minHow to scale a website from 1 user to 1 million usersSystem Design · 5 minWhat is Kafka? Why it keeps messages after you read them
Start here
01Why is 0.1 + 0.2 not 0.3 in code?02How does Git work inside? (Snapshots, not changes)03How does your computer know the time? (And why it can be wrong)