Typeahead: prefix lookup and precomputed suggestions
In a big music shop, records sit in racks sorted A to Z by artist. When a customer says "Ma…", an assistant could flick through every record in the M rack to find the most popular. The shop prints divider cards instead: one at "M", one at "Ma", one at "Mad", each listing the ten artists customers ask for most under it. The cards are rewritten every Monday from the week's till receipts, and the busiest few are copied onto a board by the door, so most customers never reach the racks.
The customer is a user typing, and what she has said so far is the prefix. The racks are every past query, held in a structure sorted by letter (a trie), and flicking through a rack is walking every completion below a prefix. The divider cards are the top ten stored for each prefix, rewritten from the till receipts, here the query log. The assistant reading a card is the suggestion service, and the board by the door is the CDN and browser cache for short prefixes. Interviewers listen for where the ranking happens, since it can't be on the keystroke. The move: rank completions offline, store the top ten for every prefix where a keystroke is one lookup, and keep the shortest prefixes at the edge.