Diagrammatic

Web Search Engine — System Design Interview Practice

Design a web search engine like Google that can index billions of web pages and return relevant results quickly. Work through the requirements, architecture trade-offs, and an interactive design review.

Concepts and architecture decisions to consider

  • searchConcept to explore
  • indexingConcept to explore
  • crawlingConcept to explore

Interview prompt

Design crawl, index, retrieve, rank, and serve web search results so users can answer a search query reliably at scale.

  • Define the source of truth for document index and crawl metadata and make retries idempotent.
  • Use bounded, partitioned state to meet billions of documents and 100K queries per second and p95 <=200ms search results.
  • Separate the critical request path from crawling, parsing, indexing, ranking, and refresh.
  • Explain consistency, failure recovery, authorization, observability, and a degraded mode.

Requirements and scale assumptions

  • Support the core workflow to answer a search query.
  • Expose status, results, and freshness appropriate to crawl, index, retrieve, rank, and serve web search results.
  • Support authorization, validation, updates, deletion, and recovery semantics.
  • Meet p95 <=200ms search results under normal load.
  • Scale to billions of documents and 100K queries per second without a single hot key or unbounded synchronous work.
  • Do not lose committed state; make retries and duplicate events safe.
  • Degrade safely when downstream workers, caches, or external dependencies fail.
  • billions of documents and 100K queries per second
  • Partition by the primary tenant, user, item, or geographic key and isolate hot partitions.
  • Keep serving state bounded; retain raw events or durable records for replay and auditing.
  • Peak scale: billions of documents — Capacity assumption that drives partitioning and backpressure.
  • Latency target: p95 <=200ms search results — User-facing budget for the primary request or read path.
  • Durable boundary: Committed before async — The source of truth is document index and crawl metadata.
  • Async boundary: At-least-once workers — Keep crawling, parsing, indexing, ranking, and refresh off the synchronous path.

Key entities

  • DocumentVersiondocumentId, sourceVersion, contentHash, aclVersion, language, updatedAt

    Canonical web search engine content and access-policy version used for indexing.

  • IndexGenerationgenerationId, sourceWatermark, schemaVersion, status, alias, createdAt

    Rebuildable web search engine index generation that can be validated before an atomic alias swap.

  • QuerySessionqueryId, tenantId, normalizedQuery, filters, generationId, nextCursor

    Auditable web search engine query context with filters, cursor, and the generation used to answer it.

  • RankingFeedbackqueryId, documentId, position, action, modelVersion, occurredAt

    Privacy-scoped web search engine relevance signal for offline evaluation and ranking improvement.

Data flow

  1. 1. Accept and authorize source changesThe web search engine ingestion boundary validates content, tenant ownership, ACLs, versions, and idempotency before publishing a document change.
  2. 2. Retrieve and rank candidatesThe query service applies authorization filters, retrieves from the active web search engine generation, ranks within the latency budget, and returns generation freshness.
  3. 3. Build a safe index generationPartitioned workers transform web search engine documents, checkpoint progress, validate counts and ACL parity, then atomically swap the serving alias.
  4. 4. Handle freshness and deletesTombstones and ACL changes propagate through the same pipeline so deleted or newly restricted web search engine content is not left searchable.
  5. 5. Measure relevance and recoverFeedback, query traces, lag, and failed partitions drive web search engine ranking evaluation, replay, and bounded degraded behavior.

Deep dives and trade-offs

  • ACL correctness and index generationsFilter web search engine results by tenant and effective ACL, or prove the active generation contains the same policy snapshot. Build shadow generations and swap aliases atomically so partial reindexes are never visible. Keep source versions and ACL snapshots for replay when permissions or content change.
  • Latency, cursors, and graceful degradationUse bounded candidate retrieval, stable sort keys, and generation-aware cursors for web search engine pagination. Serve the last healthy generation when a new build is incomplete, but expose freshness and avoid silently violating authorization. Protect the query path with timeouts, circuit breakers, and per-tenant quotas.
  • Relevance feedback without leakageSeparate web search engine click or conversion signals from personally identifying data and honor retention or deletion requests. Evaluate ranking by query class and tail latency, not only aggregate click-through. Use replayable query sets and staged model or synonym changes before production rollout.
  • Synchronous indexing versus queued indexingCommit the source version synchronously and index asynchronously with a visible freshness contract. Waiting for index mutation makes writes fragile and cannot guarantee immediate consistency at scale.
  • Denormalized ACL fields versus filter-time checksDenormalize safe, versioned authorization facts when it meets the policy model, while retaining a source-of-truth check for sensitive results. Stale permissions can become a data-leak path if index updates are treated as authoritative.
  • Lexical, vector, or hybrid retrievalStart with the retrieval method that matches the corpus and latency budget, then add hybrid ranking behind an experiment and rollback boundary. Adding embeddings without freshness, explainability, or access-control design increases cost without improving user trust.
Diagrammatic — system design practice and architecture review.