Problem statement
Design a search autocomplete service that returns the top-ranked query completions for whatever prefix a user has typed so far, updating on every keystroke (think the suggestion dropdown under a large search box).
Operating context. The service backs the main search bar of a high-traffic content site. Suggestions are drawn from a corpus of roughly 200 million distinct historical queries, each carrying a popularity score derived from how often people search it. A request arrives on nearly every keystroke, so traffic is extreme: about 120,000 prefix lookups/sec at steady state, spiking past 400,000/sec during big events. Each lookup must return up to 10 completions ranked by popularity. The corpus is heavily skewed — a small set of short, common prefixes ("ne", "wea", "you") accounts for a large share of all lookups. Popularity shifts constantly as new queries trend, but a completion appearing a few minutes late is acceptable; a slow dropdown is not.
Out of scope. Spell correction and fuzzy/typo-tolerant matching, the search results page itself, natural-language query understanding, the pipeline that mines raw query logs into cleaned candidate strings, and abuse/profanity filtering of suggestions. Assume upstream teams own those.
What to produce. A high-level architecture covering: the request path from keystroke to ranked suggestions; the prefix-index data structure and how it stores top completions per node at this scale; how the corpus is partitioned/sharded so no single node holds the whole index; how popularity ranking is applied and kept fresh (the real-time-signal vs periodic-rebuild split); the caching strategy for hot prefixes; and a hook for later personalization without rebuilding the core. Sketch the major components and the request flow between them; we will probe specifics during checkpoints.
Requirements
This assessment is a Premium feature.
The statement above is free to read. The functional and non-functional requirements, and the graded canvas that scores your design against them, come with Premium.
Topics
- System Design HLD
- Data Cache
- Scaling Read-Heavy
- Reliability Replication
- Search Index