01

Requirements & scope

Problem Statement & Requirements

Functional Requirements

  • Web crawling -- discover and fetch billions of web pages continuously
  • Indexing -- build an inverted index mapping terms to documents
  • Query processing -- parse and understand user queries (spell correction, synonyms, intent)
  • Ranking -- return the most relevant results using signals like PageRank, content relevance, freshness
  • Snippet generation -- extract and highlight relevant text snippets for each result
  • Autocomplete / suggestions -- suggest queries as user types (covered in separate design)
  • Image / video / news verticals -- blend different content types into results
  • Ads integration -- serve relevant ads alongside organic results
  • Personalization -- tailor results based on user history, location, language
  • Knowledge panels -- structured answers for entities (people, places, companies)
  • Safe search / content filtering -- filter explicit or harmful content

Non-Functional Requirements

  • Ultra-low latency -- search results in < 200 ms (end-to-end)
  • High availability -- 99.99% uptime, search must never go down
  • Massive scale -- index 100B+ web pages, serve 100K+ QPS
  • Freshness -- breaking news indexed within minutes; general web within days
  • Relevance quality -- users find what they need in first 3 results (high precision)
  • Fault tolerance -- no single point of failure; graceful degradation
  • Global distribution -- low latency for users worldwide

Scope Boundaries

In ScopeOut of Scope
Web crawling & page fetchingBrowser / client implementation
Inverted index constructionAd auction / bidding system (simplified)
Query parsing & rankingGmail / YouTube search (different domains)
PageRank computationFull NLP / LLM-based answers
Serving infrastructureDetailed spam/SEO penalty systems
Snippet generationDetailed personalization ML models
02

Scale estimations

Scale Estimations

Index & Content

MetricValue
Total indexed web pages100B
Average page size (compressed HTML)30 KB
Average unique terms per page500
Total unique terms in corpus~1B
Total raw page storage100B x 30 KB = 3 PB
Inverted index size~500 TB (compressed, with positions)
PageRank vector100B pages x 8 bytes = 800 GB
URL metadata store100B x 200 bytes = 20 TB

Crawling

MetricValue
Pages crawled per day5B
Crawl rate~58K pages/sec
Raw bandwidth (crawling)58K x 100 KB avg = ~5.8 GB/s
Re-crawl cycle (popular pages)Hours
Re-crawl cycle (long-tail pages)Weeks to months
Unique domains~500M

Query Traffic

MetricValue
Queries per day8.5B
Queries per second (avg)~100K QPS
Queries per second (peak)~300K QPS
Average query length3-4 words
Average results returned10 per page
Cache hit rate (popular queries)~30-40%

Storage Summary

ComponentSize
Raw page store (compressed)3 PB
Inverted index (sharded)500 TB
Document metadata20 TB
PageRank + link graph5 TB
Query logs (30 days)50 TB
Total~3.6 PB

Bandwidth & Compute

MetricValue
Serving bandwidth (results)100K QPS x 50 KB = 5 GB/s
Index servers needed~10,000+ (sharded by doc range)
Serving replicas per shard3-5 (for availability + load)
Total serving machines~30,000-50,000
03

Layered architecture

Phase 1 of 4 · Client & edge

Start with the entry points

First, define who uses the system and where requests enter. This is the boundary of the design, not yet a complete request path.

Search client
Start with a query, language, and an explicit result latency budget.
Architecture after phase 1. Includes Search client.
Phase 1 — Start with Search client.SVGSVGEditable diagramEditable diagram

This first layer defines the system boundary. The next chapters add application logic and data dependencies. After examining the request paths and tradeoffs, we will add operational safeguards and bring the complete architecture together.

04

API & contracts

Phase 2 of 4 · Application & compute

Add the application logic

Keep the entry points and add the services that do the work. Give each service a clear responsibility before defining its contracts. Storage and background dependencies come next.

Query frontend
Normalize tokens and interpret query intent before asking index shards for candidates.
Crawler + parser
Discover documents and extract normalized text and link metadata asynchronously.
Indexer
Create term-to-document postings and publish versioned index segments.
Architecture after phase 2. Includes Search client, Query frontend, Crawler + parser, Indexer. Search client connects to Query frontend. Crawler + parser connects to Indexer.
Phase 2 — Added Query frontend, Crawler + parser, Indexer. Earlier layers remain in place.SVGSVGEditable diagramEditable diagram

A search request carries the query, locale, filters, and pagination context. The response should distinguish no matches from incomplete results caused by a failed shard. Keep internal ranking features out of the public contract, and use a stable cursor or search snapshot when deep pagination must remain consistent.

05

Data model

Phase 3 of 4 · Data & async work

Connect data and background work

The services now need their dependencies: durable state, fast lookups, or work that continues outside a request. Separate these responsibilities rather than treating every component as a database.

Index shards
Search shards in parallel with bounded timeouts and merge their top candidates.
Document store
Keep document content available for snippets without bloating the searchable posting lists.
Ranking service
Combine text relevance, link signals, and freshness, then return a bounded result set.
Architecture after phase 3. Includes Search client, Query frontend, Crawler + parser, Indexer, Index shards, Document store, Ranking service. Search client connects to Query frontend. Crawler + parser connects to Indexer. Indexer connects to Index shards. Crawler + parser connects to Document store. Query frontend connects to Index shards. Index shards connects to Ranking service. Ranking service connects to Document store.
Phase 3 — Added Index shards, Document store, Ranking service. Earlier layers remain in place.SVGSVGEditable diagramEditable diagram

Data Storage Architecture

Storage Layer Summary

ComponentTechnologySizePurpose
Raw page storeDistributed FS (GFS/Colossus)3 PBCompressed HTML of crawled pages
Inverted indexCustom SSTable format500 TBTerm → posting lists
Document storeBigtable / custom column store20 TBURL, title, metadata, cached content
Link graphCustom adjacency format5 TBPage-to-page links for PageRank
PageRank scoresIn-memory + SSTable800 GBStatic rank per page
Query logsDistributed log (Kafka → Colossus)50 TB/moUser queries for ML training, analytics
Result cacheIn-memory (distributed)100 GB/DCCached SERP for popular queries
Posting list cacheIn-memory (per machine)64 GB/machineHot posting lists
Spell correction modelIn-memory10 GBDictionary + language models

Index Server Architecture (Single Machine)

Index Server Architecture (Single Machine)
Index Server Architecture (Single Machine)SVGSVGEditable diagramEditable diagram
06

Core design decisions

Ranking System

Multi-Phase Ranking Architecture

Multi-Phase Ranking Architecture
Multi-Phase Ranking ArchitectureSVGSVGEditable diagramEditable diagram

Key Ranking Signals

Signal CategorySignalsWeight
Text relevanceBM25, TF-IDF, term positions, phrase match, title matchHigh
Link analysisPageRank, # of inbound links, link quality, anchor textHigh
Content qualityDomain authority, content length, reading level, E-E-A-TMedium-High
FreshnessPage age, last modified, content change rateMedium
User signalsClick-through rate, dwell time, pogo-sticking rateMedium
TechnicalPage speed, mobile-friendly, HTTPS, Core Web VitalsMedium
PersonalizationUser location, language, search historyLow-Medium
Spam signalsKeyword stuffing, cloaking, link farms, thin contentNegative

BM25 Scoring Formula

EXAMPLE
BM25(D, Q) = Σ  IDF(qi) × [ f(qi, D) × (k1 + 1) ]
            qi∈Q           [ f(qi, D) + k1 × (1 - b + b × |D|/avgdl) ]

Where:
  qi        = i-th query term
  f(qi, D)  = term frequency of qi in document D
  |D|       = document length (in terms)
  avgdl     = average document length across corpus
  k1        = 1.2 (term frequency saturation parameter)
  b         = 0.75 (document length normalization)
  IDF(qi)   = log((N - n(qi) + 0.5) / (n(qi) + 0.5) + 1)
  N         = total number of documents
  n(qi)     = number of documents containing qi

PageRank Algorithm

EXAMPLE
PageRank(A) = (1 - d) + d × Σ  PageRank(T) / OutLinks(T)
                              T∈BackLinks(A)

Where:
  d = damping factor = 0.85
  T = pages that link to page A
  OutLinks(T) = number of outbound links from page T

Computation at scale:

PageRank Algorithm
PageRank AlgorithmSVGSVGEditable diagramEditable diagram

Optimizations:

  • Partition by host: Pages on same host tend to link to each other → locality
  • Dead-end handling: Pages with no outlinks distribute rank to all pages (random surfer)
  • Spam resistance: TrustRank propagates trust from seed set of known-good pages
  • Topic-sensitive PageRank: Compute per-topic PageRank vectors for better relevance
07

Request flows

Indexing Pipeline

Document Processing Flow

Document Processing Flow
Document Processing FlowWide diagram — scroll horizontally.SVGSVGEditable diagramEditable diagram

Inverted Index Structure

Inverted Index Structure
Inverted Index StructureSVGSVGEditable diagramEditable diagram

Posting list encoding (compression):

  • DocID gaps: Store delta-encoded DocIDs (42, +1295, +8662) instead of absolute
  • Variable byte encoding (VByte): Small gaps = 1 byte, large gaps = 2-4 bytes
  • Block-based compression: Group 128 DocIDs per block, compress with PForDelta
  • Skip pointers: Every 128 docs, store a skip pointer for fast intersection

Index size math:

  • 100B documents x 500 unique terms/doc = 50 trillion postings
  • Average posting size (compressed): ~8 bytes (docID gap + TF + positions compressed)
  • Total: ~400 TB raw, ~500 TB with skip pointers + term dictionary

Index Sharding Strategy

Index Sharding Strategy
Index Sharding StrategySVGSVGEditable diagramEditable diagram

Two sharding approaches:

ApproachDocument-PartitionedTerm-Partitioned
StrategyEach shard holds ALL terms for a subset of docsEach shard holds ALL docs for a subset of terms
Query routingBroadcast to ALL shards (scatter-gather)Route to specific shards based on query terms
ProsBalanced load; easy to add docsLess fan-out per query
ConsEvery query hits every shardSkewed load (popular terms); multi-term queries still hit multiple shards
Used by Google?Yes (document-partitioned)No (too imbalanced)

Google's choice: Document-partitioned indexing

  • ~10,000-100,000 shards, each holding ~1M-10M documents
  • Each shard is replicated 3-5 times for availability + load balancing
  • Query is broadcast to all shards; each returns top-K results; aggregator merges

Incremental Indexing

Incremental Indexing
Incremental IndexingSVGSVGEditable diagramEditable diagram
  • Base index: Rebuilt every few days via MapReduce over entire corpus
  • Real-time index: Streaming pipeline (like Percolator) for fresh content
  • Merge: At query time, results from both are unioned and ranked together
  • Freshness target: Breaking news pages indexed in < 2 minutes

Query Processing Pipeline

End-to-End Query Flow

End-to-End Query Flow
End-to-End Query FlowWide diagram — scroll horizontally.SVGSVGEditable diagramEditable diagram

Query Understanding Details

Spell correction:

  • Edit distance (Levenshtein) against dictionary of known terms
  • Noisy channel model: P(correct | misspelled) ∝ P(misspelled | correct) × P(correct)
  • Training data: query logs with user reformulations ("appel pie" → user clicked "apple pie" results)

Query expansion:

  • Synonym expansion: "car" → also search "automobile", "vehicle"
  • Stemming: "running" → "run" (Porter stemmer or language-specific)
  • Phrase detection: "New York" treated as single token, not "New" AND "York"

Intent classification:

IntentExampleAction
Navigational"facebook login"Boost facebook.com to #1
Informational"how to bake bread"Show featured snippet, recipes
Transactional"buy iPhone 16"Show shopping results, ads
Local"pizza near me"Show map pack, local results

Posting List Intersection (Core Algorithm)

For query "apple pie recipe", we intersect 3 posting lists:

EXAMPLE
apple:   [2, 5, 12, 42, 55, 100, 1337, ...]      (1M docs)
pie:     [5, 12, 20, 42, 88, 1337, ...]            (500K docs)
recipe:  [12, 42, 67, 1337, 5000, ...]              (2M docs)

Algorithm: Two-pointer intersection with skip pointers

Step 1: Start with shortest list (pie: 500K docs)
Step 2: For each docID in pie, binary search / skip in apple and recipe
Step 3: If found in all three → candidate

Result: [12, 42, 1337, ...]    (intersection)

Optimization: WAND (Weighted AND) algorithm
- Don't require ALL terms to match
- Score threshold: skip docs that can't beat current top-K score
- Upper bound per term: max contribution any doc can get from that term
- Skip entire blocks of posting list when upper bound sum < threshold

WAND Algorithm (Weak AND):

EXAMPLE
For each term t in query:
    upper_bound[t] = max TF-IDF score any doc can get for t

sorted_terms = sort terms by current posting list pointer (ascending docID)

while not done:
    // Find pivot: first term where cumulative upper bounds >= threshold
    cumulative = 0
    for i, term in sorted_terms:
        cumulative += upper_bound[term]
        if cumulative >= threshold:
            pivot_doc = posting_ptr[term].current_doc
            break

    // Advance all terms before pivot to pivot_doc
    // If all terms reach pivot_doc, fully score it
    // If score > threshold, add to top-K heap, update threshold
08

Performance & caching

Cache popular queries only with the context that changes their answer: language, filters, permissions, and index version where needed. Shards can keep frequently accessed index blocks warm. Bound candidate counts before expensive reranking so an unusually broad query cannot consume an unbounded share of serving capacity.

09

Advanced design

Web Crawling Subsystem

URL Frontier (Priority Queue)

The URL frontier determines what to crawl next. It must balance freshness, importance, and politeness.

URL Frontier (Priority Queue)
URL Frontier (Priority Queue)SVGSVGEditable diagramEditable diagram

Priority assignment:

  • P0 (minutes): Major news sites, trending topics, high-PageRank pages
  • P1 (hours): Popular sites, frequently updated content
  • P2 (days): Medium-traffic sites, blogs
  • P3 (weeks-months): Long-tail pages, rarely changing content

Politeness policy:

  • Respect robots.txt -- fetch and cache per domain
  • Max 1 request per domain per second (configurable)
  • Back-queue per host ensures sequential per-host fetching
  • Exponential backoff on errors (429, 503)

Crawler Worker Flow

Crawler Worker Flow
Crawler Worker FlowWide diagram — scroll horizontally.SVGSVGEditable diagramEditable diagram

Deduplication Strategy

LevelTechniquePurpose
URL-levelNormalize URLs + Bloom filter (100B entries, ~120 GB)Avoid re-fetching same URL
Content-levelSimHash / MinHash fingerprintDetect near-duplicate pages
Document-levelExact content hash (SHA-256)Detect exact duplicates

SimHash for near-duplicate detection:

  1. Tokenize page into shingles (3-grams of words)
  2. Hash each shingle to 64-bit value
  3. Compute weighted sum -> 64-bit fingerprint
  4. Two pages with Hamming distance ≤ 3 are near-duplicates
  5. Use multi-probe lookup table for efficient comparison

PageRank & Link Graph

Link Graph Storage

Link Graph Storage
Link Graph StorageSVGSVGEditable diagramEditable diagram

PageRank Convergence

EXAMPLE
Iteration   Max ΔPageRank    Time per iteration
    1          0.50              ~2 hours
    5          0.10              ~2 hours
   10          0.02              ~2 hours
   20          0.005             ~2 hours
   40          0.0001            ~2 hours
   50          < 0.00001         CONVERGED

Total compute: ~100 hours on 10,000 machines
Frequency: Recomputed weekly (or continuously with incremental updates)

Beyond Basic PageRank

VariantPurposeHow
TrustRankCombat spamPropagate trust from curated seed set of high-quality pages
Topic PageRankTopical relevanceCompute separate PageRank per topic (bias random surfer toward topic pages)
HITSAuthority vs HubAuthorities = pages pointed to by hubs; Hubs = pages pointing to authorities
Personalized PageRankUser-specificBias random surfer toward user's interests (expensive; precompute for segments)

Snippet Generation

Snippet Selection Algorithm

EXAMPLE
For each result document (top 10):

1. Fetch cached page content (from content store or cache)

2. Split page into sentences / passages

3. For each passage, compute relevance score:
   - Term overlap with query (weighted by IDF)
   - Position in document (earlier = higher weight)
   - Proximity of query terms to each other
   - Is passage in a heading, list, or structured element?
   - Does passage form a complete thought?

4. Select best passage (highest score)

5. Truncate to ~160 characters, respecting word boundaries

6. Bold query terms in snippet:
   "The best <b>apple pie recipe</b> uses Granny Smith <b>apples</b>
    with a flaky butter crust..."

7. Cache snippet for this (query, docID) pair

Featured Snippets (Position Zero)

Featured Snippets (Position Zero)
Featured Snippets (Position Zero)SVGSVGEditable diagramEditable diagram

Ads Integration

Ad Serving in Search Results

Ad Serving in Search Results
Ad Serving in Search ResultsSVGSVGEditable diagramEditable diagram

Ad Rank = Bid × Quality Score

  • Quality Score = f(expected CTR, ad relevance, landing page experience)
  • Winner pays: (next ad rank / winner's quality score) + $0.01

Advanced Topics

Semantic Search (Neural Retrieval)

Semantic Search (Neural Retrieval)
Semantic Search (Neural Retrieval)Wide diagram — scroll horizontally.SVGSVGEditable diagramEditable diagram

Real-Time Indexing Pipeline (Google Caffeine)

Real-Time Indexing Pipeline (Google Caffeine)
Real-Time Indexing Pipeline (Google Caffeine)SVGSVGEditable diagramEditable diagram

Handling Scale: Tiered Index

EXAMPLE
Tier 1: "Hot" index (top 10B pages by PageRank)
  - Fully in-memory posting lists
  - Serves 80% of queries (popular terms + high-quality pages)
  - Fastest response time

Tier 2: "Warm" index (next 40B pages)
  - SSD-backed posting lists, cached in memory when hot
  - Queried only if Tier 1 doesn't return enough results
  - Slightly slower

Tier 3: "Cold" index (remaining 50B pages)
  - SSD/HDD-backed
  - Only queried for rare/long-tail queries
  - Slowest but most comprehensive

Query flow:
  1. Always query Tier 1
  2. If < 10 good results, also query Tier 2
  3. If still < 10, query Tier 3
  4. Merge and re-rank across tiers
10

Edge cases

A document can change after retrieval but before the reader opens it. Preserve a version or crawl timestamp so snippets are explainable. Deleted or access-restricted documents need prompt filtering, and a slow shard needs an explicit timeout policy rather than holding every other shard’s results indefinitely.

11

Tradeoffs

Key Tradeoffs

Freshness vs. Index Quality

Freshness vs. Index Quality
Freshness vs. Index QualitySVGSVGEditable diagramEditable diagram

Precision vs. Recall

ApproachPrecisionRecallLatencyUse Case
Strict AND (all terms must match)HighLowFastShort queries, navigational
WAND (soft matching)Medium-HighHighMediumMost queries
Neural retrieval (embedding similarity)MediumVery HighSlowAmbiguous / semantic queries
Hybrid (WAND + neural)HighVery HighMediumBest quality, Google's direction

Document-Partitioned vs. Term-Partitioned Index

CriterionDocument-PartitionedTerm-Partitioned
Fan-out per queryHigh (all shards)Low (few shards)
Load balanceEvenSkewed (popular terms)
Adding documentsEasy (add to one shard)Hard (update many shards)
Multi-term queriesNatural (local intersection)Complex (distributed join)
Failure impactGraceful (partial results)Total (missing term = broken)
WinnerGoogle uses thisNot used at scale

Pre-computation vs. On-the-fly

ComponentPre-computedOn-the-flyGoogle's Approach
PageRankWeekly batchN/APre-computed
Inverted indexBatch + real-timeN/AHybrid
SnippetsN/AAt query timeOn-the-fly (cached)
Spell correctionModel trained offlineApplied at query timeHybrid
PersonalizationUser profile prebuiltApplied at ranking timeHybrid
ML ranking modelTrained offlineInference at query timeHybrid

Latency vs. Quality

EXAMPLE
Budget: 200 ms total

If we spend MORE time on ranking:
  + Better result quality (more features, deeper models)
  - Higher latency → users leave (Google data: +200ms = -0.6% searches)
  - More compute cost

If we spend LESS time on ranking:
  + Faster results → happier users
  + Lower compute cost
  - Worse relevance → users reformulate / leave

Solution: Multi-phase ranking
  - Cheap phases process many candidates quickly
  - Expensive phases only run on small candidate set
  - Strict timeout per phase with fallback to simpler model
12

Reliability & fault tolerance

Phase 4 of 4 · Operations & resilience

Add operational safeguards

With the request paths and tradeoffs established, add the controls that help detect trouble and keep the system operating. The final diagram retains every layer introduced so far.

Operations
Track index lag and slow shards; return partial results rather than waiting indefinitely.
Architecture after phase 4. Includes Search client, Query frontend, Crawler + parser, Indexer, Index shards, Document store, Ranking service, Operations. Search client connects to Query frontend. Crawler + parser connects to Indexer. Indexer connects to Index shards. Crawler + parser connects to Document store. Query frontend connects to Index shards. Index shards connects to Ranking service. Ranking service connects to Document store. Index shards connects to Operations.
Phase 4 — Added Operations. Earlier layers remain in place.SVGSVGEditable diagramEditable diagram

Fault Tolerance & Reliability

Replication Strategy

Replication Strategy
Replication StrategySVGSVGEditable diagramEditable diagram

Failure Scenarios & Handling

FailureImpactMitigation
Single index server dies1 shard's replica unavailableOther replicas serve; re-replicate from peers
Entire rack failsMultiple shards affectedCross-rack replicas; partial results from remaining shards
Entire DC failsNeed other DC to serveFull index copy in each DC; DNS failover
Index corruptionWrong resultsChecksum validation; rollback to previous index version
Crawler overloads targetSite goes downPoliteness policies, adaptive rate limiting
Query of death (pathological query)Server OOM/timeoutQuery complexity limits, timeout per phase, circuit breaker

Graceful Degradation

When the system is under stress:

  1. Drop neural re-ranking (Phase 3) -- fall back to ML tree model (saves ~30ms)
  2. Reduce shard fan-out -- query subset of shards (partial results, still useful)
  3. Increase cache TTL -- serve slightly stale results
  4. Shed low-priority queries -- deprioritize bot traffic, prefetch requests
  5. Disable personalization -- serve generic results (cheaper to compute)

Monitoring & Operational Concerns

Key Metrics to Monitor

CategoryMetricAlert Threshold
LatencyP50 query latency> 100 ms
LatencyP99 query latency> 500 ms
AvailabilityShard availability< 99.9%
QualityClick-through rate (CTR) on #1 resultDrop > 5%
QualityQueries with no results> 0.1%
FreshnessTime from page publish to indexing> 5 min for P0 pages
CrawlingCrawl error rate> 5%
CrawlingPages crawled per secondDrop > 20%
IndexIndex staleness (oldest segment age)> 7 days
CapacityIndex server CPU utilization> 70% sustained
CapacityMemory utilization per index server> 85%

Operational Runbook Scenarios

ScenarioResponse
Query latency spikeCheck for hot shards; shed neural re-ranking; increase cache TTL
Index corruption detectedRollback shard to last known-good checkpoint; alert indexing team
Crawl rate dropCheck DNS resolution; check for widespread 429s; verify frontier health
Quality regressionRoll back ranking model; check for data pipeline issues
DC failover neededDNS reroute traffic; verify receiving DC has capacity headroom
13

Production architecture

High-Level Architecture

High-Level Architecture
High-Level ArchitectureSVGSVGEditable diagramEditable diagram

Detailed Architecture

Detailed Architecture
Detailed ArchitectureWide diagram — scroll horizontally.SVGSVGEditable diagramEditable diagram

Serving Infrastructure

Global Distribution

Global Distribution
Global DistributionSVGSVGEditable diagramEditable diagram

Caching Layers

EXAMPLE
Layer 1: Result Cache (in-memory, per DC)
  Key: normalized_query + locale + page
  Value: serialized search results (top 10 + snippets)
  TTL: 5-15 minutes
  Hit rate: ~30% (head queries)
  Size: ~100 GB per DC

Layer 2: Posting List Cache (in-memory, per index server)
  Key: term
  Value: compressed posting list (or partial)
  Policy: LRU, prioritize high-IDF terms
  Hit rate: ~80% for popular terms
  Size: ~64 GB per machine

Layer 3: Document Cache (in-memory)
  Key: doc_id
  Value: title, URL, cached snippet, metadata
  Size: ~32 GB per machine

Layer 4: DNS Cache
  Resolved hostnames cached for crawlers
  TTL: follow DNS TTL headers

Latency Budget Breakdown

Latency Budget Breakdown
Latency Budget BreakdownSVGSVGEditable diagramEditable diagram

Tail Latency Management

StrategyDescription
Hedged requestsSend query to 2 replicas of each shard; use first response
Canary requestsSend to 1 shard first; if slow, don't fan out to rest
Backup requestsIf primary shard doesn't respond in P50 time, send to backup
Graceful degradationIf some shards timeout, return partial results from responding shards
Tiered timeoutPhase 3 (neural) skipped if time budget exhausted; fall back to Phase 2
14

Further exploration

Search for a breaking news event a minute after it starts. Compare a fresh but noisy incremental index with yesterday’s more thoroughly processed index. Work through how they merge, how duplicates disappear, and how ranking avoids treating freshness as a universal substitute for relevance.

15

Interview playbook

System Design Interview Tips

What interviewers are looking for

  1. Crawling at scale -- URL frontier design, politeness, deduplication
  2. Inverted index internals -- posting lists, compression, skip pointers
  3. Ranking pipeline -- multi-phase architecture, key signals, BM25 + PageRank
  4. Serving at scale -- sharding, replication, caching, latency budgets
  5. Tradeoff reasoning -- freshness vs quality, precision vs recall, cost vs latency

Common follow-up questions

QuestionKey Points
"How do you handle a query that matches 1B documents?"WAND pruning, tiered index, early termination with top-K heap
"How do you keep the index fresh?"Real-time pipeline (Caffeine), incremental indexing, merge with base
"How would you handle a celebrity name query?"Intent classification, knowledge panel, blend web + news + images
"What happens if a data center goes down?"Full index replica per DC, DNS failover, hedged requests
"How does PageRank handle spam?"TrustRank from seed set, link farm detection, manual penalties
"How do you evaluate search quality?"Human raters (E-E-A-T), A/B tests on CTR/dwell time, NDCG metric

Suggested 45-Minute Interview Structure

EXAMPLE
0-5 min:   Clarify requirements (web search? scale? real-time?)
5-10 min:  Scale estimations (pages, QPS, storage)
10-20 min: High-level architecture (crawl → index → serve)
20-30 min: Deep dive into ONE area:
           - Option A: Inverted index + query processing
           - Option B: Crawling + URL frontier
           - Option C: Ranking pipeline
30-40 min: Tradeoffs + scaling concerns
40-45 min: Monitoring, failure handling, future extensions