Design Search Autocomplete / Typeahead - System Design
Everyone thinks autocomplete is a LIKE 'prefix%' query. “Index the search terms, run a prefix match, return the top ten, done.” Then the interviewer adds the real constraints: the dropdown must update on every keystroke, so you are firing a query every ~50ms while someone types; it must feel instant, which means the whole round trip - network, lookup, ranking, render - has a budget under 100ms; the corpus is billions of queries and the popular ones shift by the hour; and “top ten” is not alphabetical, it is ranked by popularity, which a prefix index does not give you for free. ...