Search Bar Autocomplete

Design the autocomplete/typeahead system behind a search bar that returns the top-K query suggestions for a partial prefix within a sub-50ms budget, at the scale of a major search engine.

00

Practice checkpoints

The requirements are open as a taste. From the numbers onward, the full guide opens in the app.

  1. 01
    Clarify scope
  2. 02
    Requirements + scale
  3. 03
    API + data modelUnlocks in the app
  4. 04
    Draw architectureUnlocks in the app
  5. 05
    Deep diveUnlocks in the app
  6. 06
    Trade-off decisionUnlocks in the app
01

Requirements that shape the design

Do not only state requirements. Ask for them. Each card pairs the design constraint with a clarification question you can say out loud before drawing the architecture.

Functional requirements

01What does the user get on each keystroke?

Up to 10 ranked completions for the current prefix, rendered fast enough to feel attached to the keystroke.

02Ranked by what — global popularity, my own history, or both?

A blend: global popularity forms the base list, and the user’s own recent queries are layered on top of it.

03A term explodes in the news — when does it show up in suggestions?

Within minutes to a couple of hours — a trending path boosts sudden risers ahead of the next scheduled rebuild.

04One language, or every script users actually type?

Multi-language and full unicode: prefixes are normalized, and each language/region gets its own suggestion set.

05Can an offensive term ever appear as a suggestion?

No — a blocklist filter runs at serve time on every response, so nothing filtered can leak through any caller.

06Does every single keystroke really fire a network request?

No — the client debounces short pauses and cancels stale in-flight responses; the server contract stays a stateless prefix → top-K lookup.

Out of scopeRanking the full results page (this is the box above the results, not the results) · Did-you-mean spell correction of the submitted query on the results page · Sponsored suggestions and the ad auction behind them

Non-functional requirements

01What latency budget do we actually have per keystroke?

p99 under 50 ms end to end — after network transit that leaves ~10 ms of server time, so the answer must already exist before the keystroke arrives.

02How much traffic is this compared to search itself?

Every keystroke is a query: suggest traffic is search QPS × average typed length, roughly 8×, and the tier is sized for that amplification.

03Stale suggestions or no suggestions — which failure is worse?

No suggestions is worse than stale suggestions: on any backend trouble, serve the last cached list — suggestions are a hint, not a source of truth.

04Is load spread evenly across prefixes?

Traffic is wildly skewed toward short prefixes — hot keys must be absorbed by replication and edge caching, never funneled onto one shard.

05How fresh does the suggestion set have to be?

Two freshness tiers: the global table may lag hours behind the logs, but a breaking term must enter within minutes.

Keep asking — the interview is a conversation

Real interviews probe far more than a tidy list. These are the scope questions that separate candidates who interrogate the problem from those who recite it.

  • Is this web-search scale — billions of searches a day — or search inside one product with a bounded catalog?
  • Is global popularity enough for launch, or is personalization a day-one requirement?
  • How fast must a breaking-news term appear — minutes, or is the next scheduled rebuild acceptable?
  • Which languages and scripts are in scope, and do suggestions differ by region?
  • Is sensitive-term filtering a per-region legal obligation, meaning the blocklist itself varies by country?
01

Unlock the full playbook for Search Bar Autocomplete

Numbers, architecture diagram, API and data model, deep dives, expected topics, self-check, whiteboard starter, and common mistakes unlock inside the app.

02

Numbers that force architecture decisions

Locked in the app

03

Architecture path

Locked in the app

04

API and data model

Locked in the app

05

Deep dive directions

Locked in the app

+Series

Practice the related series