sydepsystem design atlas

Typeahead Autocomplete

Serve prefix suggestions from a fast, prefix-optimised index.

IntermediateWebData
UserClientAutocomplete ServiceComputePrefix IndexStorageIndex BuilderComputeCorpusStorage

User input is sent to an autocomplete service that queries a prefix index over the known corpus and returns a small ranked list, with the backing corpus and popularity signals updated asynchronously by batch jobs.

When to use it

  • Users need instant suggestions while they type
  • The corpus is much larger than the number of suggestions you want to show each query

Trade-offs

  • Prefix index freshness can lag the latest content if updates are batched
  • Ranking quality often needs separate relevance tuning from the storage engine

Components used

Web AppManaged App ServiceSearch IndexBatch / Scheduled JobObject Storage

How it works

  • Suggestions are served from a prefix-optimised structure — a trie or an edge-n-gram index — rather than a wildcard database query.
  • Popular completions are precomputed per prefix and cached, so a keystroke costs a lookup rather than a search.
  • The client debounces input and cancels in-flight requests, since a user typing eight characters must not generate eight competing responses.

Used in the wild

  • Search box suggestions on commerce and content sites.
  • Address and location completion.
  • Command palettes and in-app entity pickers.

Good to know

  • The latency budget is roughly 100ms. Beyond that the suggestions arrive after the user has already typed past them, which feels worse than having none.
  • Out-of-order responses are the classic bug: an earlier request returns after a later one and overwrites the correct suggestions with stale ones. Sequence numbers or request cancellation are required.