Question
Design a *personalized* typeahead for a marketplace search box at 1M autocomplete QPS, p99 < 40ms. The catch: the suggestion list for a given prefix must blend three sources at request time — a global popularity-ranked completion trie, this user's own recent searches and purchases (the last ~90 days), and what's hot in the user's *current session* (e.g. they just searched 'tent', so 'sleeping bag' should rise). You must not regress the 40ms budget by doing a per-request ML scoring round trip. How do you structure the index, where does personalization live, and how do you merge the three lists deterministically?
Clarify scale and constraints first. Propose a clean component breakdown, then go deep on the hard parts — data model, bottlenecks, consistency, failure modes — and name the trade-offs you are making.