Skip to content
StackDecode
System Design
20. System Design Case StudiesAnimated

Search Autocomplete System

Suggest completions as the user types.

The idea

A trie or prefix index returns top suggestions quickly, updated from query logs.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

Typing "sys"Edge cacheTrie / prefix i…RankerQuery log pipel…
  • client
  • gateway / proxy
  • service
  • cache
  • data store
  • queue / stream

Each keystroke sends the prefix (debounced).

step:
1/4
at:
Typing "sys"
1/10

The green dot is a request moving through the system.

Step by step

  1. 1User types a prefix
  2. 2The index finds matching completions
  3. 3Rank by popularity
  4. 4Return the top few within milliseconds

Where it is used

Search boxes.

Watch out for

Latency budget and offensive suggestions.

Related