May we use cookies so Meta, Google, LinkedIn and ChatGPT see your visit and we learn which ads work? PrivacyMay we use cookies to see which pages help, and let Meta, Google, LinkedIn and ChatGPT see your visit, so we know which of our ads work? That way we spend less on ads that do not work. We do not sell your data, and the site works the same if you decline. You can change your answer at any time under Cookie settings at the foot of the page. Privacy policy
Loading...
System Design and AI Engineering, by Roni Das. 989 interactive lessons in two courses.: 770 in System Design and 219 in AI Engineering.
Start LearningSystem design interview guide
Short answer
Google search system design has an offline path and an online path. Offline, crawlers fetch pages and an indexing pipeline builds an inverted index that maps each word to the documents that contain it, split into shards by document. Online, a query goes to every shard, each returns its best matches, and a mixer merges and ranks them.
in this guide
7 parts open to everyone · 3 with a free account · 3 with the course
You can read 7 of 13 parts. A free account opens the deep dive; the course opens all of it.
Interviewers like this problem because it forces a candidate to reason about the largest read-heavy system there is and to make an explicit trade between latency and completeness. It touches nearly every core topic: partitioning strategy, replication, fan-out and aggregation, tail latency, caching, batch versus incremental pipelines, and ranking as a distinct concern from retrieval. A strong candidate separates the offline indexing path from the online serving path early, chooses document partitioning over term partitioning and can defend it, and shows they understand that the 99th percentile latency of a fan-out query is governed by the slowest shard, not the average one.
This page is the free part.
₹1,111 in India$35 everywhere elseonce, for the whole course
The System Design course covers the Google Search design across a run of lessons, not one page. These 4 alone are about 111 minutes of step-by-step reading, every one with a quiz.
Always clarify these in the first 5 minutes of the interview. Do not start drawing boxes until both lists are agreed.
This guide is built on these 5 lessons. Each one teaches one piece of the Google Search design above, step by step.
Lifetime access for ₹1,111 in India or $35 elsewhere. Interactive diagrams, quizzes, and 20 capstone projects to practise on.
This one question is not enough for the interview.
Each question has why it is asked, a full answer, what the interviewer listens for, the follow-ups, the common mistakes and a diagram (268 diagrams in all). A PDF you keep, junior to staff level.
Two courses by the author of this page:
770 lessons · 18 free to read
₹1,111 in India · $35 elsewhere, once
Get System DesignYou own this course
219 lessons · 10 free to read
₹1,333 in India · $35 elsewhere, once
Get Generative AI and Agentic AIYou own this course
Save your progress and get the interview checklist PDF
Google fields on the order of 100,000 searches every second, which works out to trillions of queries a year against an index of hundreds of billions of documents (roughly 400 billion documents as of 2020, per public reporting). The hard part is not storing that corpus. It is answering an arbitrary two-word query against all of it, ranking the results, and painting ten blue links in under a fifth of a second, every single time.
Google Search is two loosely coupled systems joined by a data structure. The offline half crawls the web, parses pages, and builds an inverted index that maps every term to the list of documents containing it, sharded across thousands of machines. The online half takes a user query, resolves it against every index shard in parallel, scores the candidate documents with PageRank plus hundreds of other signals, and merges the top results. The central tension is scale versus latency: the index is far too large for one machine, so it is partitioned by document into shards that are each replicated many times, and a query fans out to all shards at once in a scatter-gather pattern. Because a single slow shard would stall the whole query, the serving path leans on in-memory posting lists, tight per-stage timeouts, hedged requests, and partial-result tolerance. On top of that sits a snippet-generation stage, a heavy caching layer for popular queries, an autocomplete service that predicts the query before it is finished, and an incremental indexing pipeline that keeps fresh pages searchable within seconds.
Where it shows up
Asked at Google, Microsoft (Bing), Amazon, Meta, and most large product companies, usually as a staff or senior level design round. It also shows up in scaled-down forms such as design a search autocomplete, design a document search service, or design an inverted index.
Spec sheetGoogle Search
worked through below, with the maths
The hard parts of this design are taught step by step in the System Design course: Database Indexing, Database Sharding and MapReduce.
The planner stopped using an index somewhere between 19.7 and 39.8 percent of the table. A query on the second column of a composite index took 37.269 ms against 0.054, and five indexes took the same inserts from 160 ms to 751.
Splitting a database across multiple servers, the nuclear option for scaling writes, and the architecture behind Instagram, Uber, and YouTube.
The programming model that launched big data, parallel processing across thousands of machines.
How a distributed cache spreads keys across nodes with consistent hashing and virtual nodes. Measured tests show why a hot key still overloads a node.
all part of
System Design Masterclass
770 lessons · about 290 hours · 18 free to read
₹1,111in India, by UPI
$35everywhere else, by card or PayPal
You own this course
Continue with Database Indexingpay once,
yours for life
Live from the course bench
Real interview questions, live diagrams and measured lab results, pulled at random from the lessons. A new set every time you come back.
Show your math. Pulling numbers from thin air signals you have not thought about the load.
Query rate
~100,000 queries/sec
Public reporting puts Google at several trillion searches per year. 5e12 / (365 * 86400) is about 158,000 queries per second averaged over the year, so a steady-state design target near 100,000 QPS with headroom for peaks is reasonable. Derived from published annual totals, treat as an estimate.
Index size (documents)
~400 billion documents
Widely reported figure for Google's serving index around 2020, drawn from trillions of URLs crawled but filtered down to what is worth serving. The crawl frontier is much larger than the served index. Estimate, not an official current number.
Raw index storage
~10s of petabytes
Derived: 400e9 documents at an average served/compressed footprint on the order of tens of kilobytes of postings and metadata per document lands in the tens of petabytes range. Order-of-magnitude estimate to justify heavy partitioning; real figures are not published.
Number of index shards
thousands
Derived: if each shard holds tens of millions of documents in memory for fast posting-list scans, 400e9 documents divided by ~5e7 per shard is on the order of 10,000 shards before replication. Exact count is not public.
Machines in the serving fleet
tens of thousands
Derived: thousands of shards, each replicated many times for both throughput and fault tolerance, plus doc servers, mixers, cache, and autocomplete tiers, pushes the serving fleet into the tens of thousands of machines. Order-of-magnitude estimate.
Per-query latency budget
< 200 ms at the tail
Google has publicly targeted sub-quarter-second responses. That budget is split across query rewriting, the scatter-gather over index shards, snippet generation on doc servers, and network hops, which is why each internal stage gets a tight timeout. Target/estimate.
Split the system into an offline path and an online path. Offline, a distributed crawler starts from a seed set and a frontier of known URLs, fetches pages while respecting robots rules and politeness delays, and stores raw content in a repository. An indexing pipeline parses each page, extracts terms and links, deduplicates near-identical content, and produces two structures: a forward index (document to its terms) and the inverted index (term to the sorted list of documents containing it, with positions and per-term metadata). The inverted index is partitioned by document into shards, so any single document lives in exactly one shard, and each shard is replicated. Link data is fed into PageRank and other graph computations that produce query-independent quality scores baked into the index. Online, a user query hits a front end that does query understanding: spelling correction, tokenization, synonym expansion, and intent signals. The rewritten query goes to a root or mixer node that scatters it to a replica of every index shard in parallel. Each index server scans its posting lists, finds documents matching the terms, applies a first-pass score, and returns its local top-k document IDs with scores. The mixer gathers these partial lists, merges them into a global top-k, and then asks the document servers to fetch titles, URLs, and to generate query-specific snippets for just those winners. A final ranking pass reorders using the heavier signals, results are assembled, and the page is returned. A results cache short-circuits popular queries, and a separate autocomplete service answers keystroke-by-keystroke as the user types.
In a real interview, sketch this on the whiteboard before diving into any single box.
Walk through each service. The interviewer wants to hear what each one owns, not just the names.
A distributed fleet that pulls URLs from a prioritized frontier, fetches pages, and honors robots.txt and per-host politeness limits. It discovers new links from fetched pages, schedules recrawls based on how often a page changes, and stores raw HTML in a content repository for the indexer. Priority and freshness scheduling decide what gets crawled next out of a frontier far larger than the served index.
Takes raw pages and produces the forward and inverted indexes. It parses and tokenizes content, records term positions for phrase matching, deduplicates near-duplicate pages, and merges new documents into the shard structure. Historically this was a batch MapReduce rebuild; the Caffeine generation moved to incremental indexing so a single new page can be added without rebuilding the whole index.
The heart of retrieval. The index is partitioned by document into thousands of shards, each holding the posting lists for its slice of the corpus, kept in memory to avoid disk seeks. Each shard is replicated many times so that read throughput scales and any single machine can fail without losing coverage. An index server scans posting lists, intersects them across query terms, and returns a local top-k.
The scatter-gather coordinator. It fans the query out to one replica of every shard, collects the per-shard partial results, and merges them into a single global ranked list. It enforces per-shard timeouts, can issue hedged (duplicate) requests to a second replica when one is slow, and returns partial results rather than stalling on a lagging shard.
Once the mixer has the winning document IDs, doc servers fetch the stored document, its title and URL, and generate a query-dependent snippet by locating the matching terms in context. This is a second fan-out but only over the handful of results that will actually be shown, so it is cheap relative to the index scan.
A layered set of signals applied at different stages. Query-independent quality (PageRank and spam scores) is precomputed into the index; a fast first-pass score runs on the index servers; heavier models such as RankBrain, BERT-based neural matching, and freshness boosts reorder the small candidate set at the top. Ranking is deliberately separate from retrieval so the expensive models only see a few hundred candidates.
A results cache stores fully rendered result sets for popular and repeated queries, absorbing a large fraction of traffic before it ever reaches the index. A separate autocomplete service serves query predictions from a prefix structure (such as a trie of popular queries with frequency weights) so suggestions appear within tens of milliseconds as the user types.
documents. The canonical record for each served page. doc_id is an internal integer used everywhere downstream so posting lists store compact IDs, not URLs. content_hash drives…
Every table for Google Search, its keys, and which store fits it and why.
Building the inverted index and why it beats scanning. A naive search scans every document for the query terms, which is impossible at web scale. The inverted index flips that: for each term you precompute the sorted list of…
7 deep dives on the parts that break at scale: Building the inverted index and why it beats scanning; Document partitioning versus term partitioning; Scatter-gather query serving and the tail latency problem.
Document partitioning versus term partitioning. Document partitioning forces every query to fan out to all shards, which is more network work per query. It wins anyway because it balances load evenly, keeps term…
6 decisions an interviewer expects you to defend, each with the alternative and why it loses here.
A whole rack holding replicas of several shards goes down. What do users see?
3 follow-up questions with model answers, the interview scorecard for this question, and a mock interview on Design Google Search with the AI tutor.
Google's public record spans decades. The original 1998 Anatomy of a Large-Scale Hypertextual Web Search Engine paper by Brin and Page described the crawler, the repository, the forward and inverted indexes stored in barrels, the lexicon, and PageRank. The 2003 Web Search for a Planet paper by Barroso, Dean, and Holzle described the serving side: queries handled by index servers that hold document-partitioned shards and return doc IDs, followed by document servers that produce snippets, all on replicated commodity hardware where replication buys both throughput and fault tolerance. The 2010 Caffeine announcement documented the move from periodic batch rebuilds to continuous incremental indexing for fresher results. On the ranking side, Google publicly documents named systems including PageRank, RankBrain, BERT-based neural matching, passage ranking, MUM, and freshness systems in its ranking systems guide. Public reporting and Google statements put current volume in the trillions of searches per year against an index measured in the hundreds of billions of documents.
Sources
If any of these topics are fuzzy, the interviewer will catch it. Each lesson is 15 to 60 minutes with diagrams, code, and a quiz.
interview readiness
Three questions from this guide. Answer them without scrolling up, the way you would have to in the room.
Pay by UPI, cards or netbanking through Razorpay. Pay by card or PayPal, in US dollars. Download at once from My packs.
NEWSystem Design Hands-On
Postgres Sharding: Complete Hands-On (PgBouncer + Citus). 2 h 36 min and 20 chapters: one PostgreSQL loaded until it breaks, then four shards behind a router you write, PgBouncer and Citus, with the 139-page slide deck. The first 15 minutes are free to watch.
Free PDF · 79 pages
25 real tech interview questions, answered in full
Five from each of our AI, GenAI, Inference, Maths for ML and Forward Deployed packs. Each with a diagram and a model answer. Free by email.
free tool
Check these numbers yourself
Put in your own guesses for Google Search and see requests per second, storage, bandwidth and servers, with every sum written out.
Open the Capacity EstimatorIt is really nice and good Please join the course