</>CodexBash
All articles
System design

Search autocomplete

Designing search autocomplete (typeahead): requirements and latency budget, tries and top-k suggestions per prefix, building suggestions offline from query logs, serving from memory with caching, sharding by prefix, debouncing and client caching, ranking, personalisation and freshness, typo tolerance, and filtering unsafe suggestions.

CodexBash, , 6 min read

As you type "how to inst" into a search box, suggestions appear instantly: "how to install python", "how to install java on windows". Autocomplete, or typeahead, looks simple but is a classic system design question because of its strict latency requirement: suggestions must appear within the time between keystrokes, for every keystroke of every user. This article designs an autocomplete service, covering the data structures, how suggestions are built, how they are served at scale, and the client-side techniques that make it feel instant.

Sign in to read the rest

The whole 6 minute article is free with an account, along with every problem, lesson and tutorial. No card.