System design interview questionMedium

Design Typeahead

Design the search-box typeahead for a large web search engine: popular completions for every prefix, shared by all users in a locale.

1. Problem Statement

When you type into the search box of a large web search engine, it suggests popular completions instantly. Everyone in the same country and language sees the same suggestions for a prefix. How would you design this typeahead system?

2. Architecture Discussion Map

Use this as one discussion aid, not a single correct answer. Your design should follow from the requirements, scale, and trade-offs you establish.

Rendering architecture diagram...
Mermaid Source (For AI Bots)
graph LR
    A["Design Typeahead"]
    A --> F1["Prefix index and top-K precomputation"]
    A --> F2["Index memory sizing and pruning"]
    A --> F3["Caching at client, edge, and server"]
    A --> F4["Offline builds, freshness, and atomic index swaps"]
    A --> F5["Safety filtering, blocklists, and privacy thresholds"]

3. Key Focus Areas

  • 1
    Prefix index and top-K precomputation
  • 2
    Index memory sizing and pruning
  • 3
    Caching at client, edge, and server
  • 4
    Offline builds, freshness, and atomic index swaps
  • 5
    Safety filtering, blocklists, and privacy thresholds

4. What the Interviewer Looks For

The interviewer probes these areas, and the report grades the interview against them.

  • Requirements and estimation
  • Prefix-serving structure
  • Data pipeline and freshness
  • Caching and client request control
  • Ranking quality, safety, and operations

5. What Strong Candidates Should Demonstrate

  • Size a prefix index from query counts and decide what to prune or shard.
  • Serve precomputed top completions per prefix within a tight latency budget.
  • Cache shared suggestions in the browser, at the edge, and on servers.
  • Keep suggestions fresh, and keep harmful or private queries out of them.

Want interactive feedback?

Practice drawing this system component-by-component on a live whiteboard while the interviewer probes at your target level.

Continue to Dashboard

Core Concepts

Tries (Prefix Trees)CachingLatencyPre-computation

Continue preparing

Build a complete software engineer mock interview plan

Prepare by company

Related System Design

Design Product Search Autocomplete

Design personalized, trend-aware autocomplete and search suggestions for a large online store's product search, built around a ranking model you are given.

Related System Design

Design Twitter Feed

Design a scalable news feed system where users can post tweets and follow other users.

Related System Design

Design a Cross-Product Tagging System

Design a shared tagging service that lets users apply tags to entities across multiple Atlassian products, with consistent search and deduplication.