Search Autocomplete

Suggest popular completions as users type, within tens of milliseconds.

Medium40 minTrieTop-KOffline aggregation

Search autocomplete (typeahead) suggests popular completions as the user types each character. It has a brutal latency budget, since a request fires on every keystroke, which pushes the design toward precomputed top-K results served from memory.

Clarify requirements

Functional

  • Given a prefix, return the top 5–10 suggestions ranked mainly by popularity.
  • Suggestions update as query trends change (daily is fine, near real-time for trending is a bonus).
  • Filter offensive or blocked terms.
  • Optional: personalization and locale; scope initially to global popularity per language.

Non-functional

  • 100M DAU, ~10 searches each, ~6 keystrokes per search that trigger a request.
  • p99 latency < 50 ms end to end (server time ~10 ms).
  • Highly available; slightly stale suggestions are fine.

Try it first

Set a timer, sketch your own design on paper, then compare it with the reference walkthrough.

40:00

Complete & continue

Defend it out loud

The AI interviewer will probe your design for Search Autocomplete and score it.

Mock interview