Design Search Autocomplete

MediumSearchTriesCachingRankingData PipelinesAbout 35 minutes

Design the typeahead behind a search box: as the user types, suggest the top 10 completions ranked by popularity, within 100 ms. Plan for 10B searches per day, with suggestions that reflect trending queries within an hour.

How the interview goes

Five phases, and questions the interviewer is likely to ask in each.

  1. 1. Requirements

    • How fresh must suggestions be?
    • Should suggestions be personalized?
    Show a hint

    Count the requests: every keystroke is a read.

  2. 2. High-level design

    • How does a search turn into a better suggestion later?
    • What is in memory and what is on disk?
    Show a hint

    Separate the read path from the path that learns from logs.

  3. 3. Deep dive

    • How do you get top 10 for a prefix without scanning?
    • How do you deploy a new index without downtime?
    Show a hint

    Store the answer at each prefix instead of computing it per request.

  4. 4. Scaling

    • How do you shard the index, and what about the prefix 's'?
    • How much can you cache?
    Show a hint

    Some prefixes are far hotter than others.

  5. 5. Trade-offs

    • Precomputed top-k costs memory; when is it worth it?
    • How would you add personalization without blowing up latency?
    Show a hint

    Freshness and serving cost pull in opposite directions.

Practice this with an AI interviewer

Write your design doc with live diagrams while the interviewer asks one question at a time and pushes on your choices. Get a scored debrief with what to study next.

Start this interview