System Design · Senior · Question 19 of 75
How do you scale search suggestions (typeahead) to millions of requests per second?
- ✓Correct answer: Precomputed top-K per prefix, edge caching, debounce
- 2Full-text search across the whole database on every keystroke
- 3Load the full dictionary of all possible suggestions into the browser
Explanation
Popular prefixes and their suggestions (a trie or key-value) are updated offline from query logs, and responses are cached on the CDN and in the browser. The client reduces requests with debounce, cancellation and a local prefix cache.