Design Search Autocomplete
Quick Overview
Design a typeahead suggestion system for a search engine. Cover trie-based data structures, ranking by popularity and personalization, real-time updates, and serving suggestions with sub-50ms latency.
0
Design a typeahead suggestion system for a search engine. Cover trie-based data structures, ranking by popularity and personalization, real-time updates, and serving suggestions with sub-50ms latency.
Autocomplete is a Google onsite favorite because it pairs a tight latency budget on every keystroke with ranking quality across billions of queries. The interviewer checks that you precompute top suggestions per prefix, keep serving fast while data refreshes, and add personalization and trending terms without breaking the 50ms target.
What the Interviewer Expects
- Clarify scope: suggestions per prefix, latency target, freshness, languages
- Use a trie or prefix table with top-N suggestions cached on each node
- Build the index offline from query logs and roll it out without downtime
- Blend popularity with personalization and recency in the ranking
- Cut load with client debouncing, edge caches and sharding by prefix
- Filter offensive or unsafe suggestions before serving
Key Topics to Cover
How to Approach This
- Start by clarifying functional and non-functional requirements with the interviewer.
- Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
- Draw a high-level architecture first, then deep dive into 1-2 critical components.
- Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
- Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
- How would you surface a breaking-news query within minutes?
- How do you shard the trie so popular prefixes do not overload one machine?
- How would you handle typos in the typed prefix?
- How do you measure whether a ranking change improved suggestions?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
- Functional Requirements:
- Provide typeahead suggestions for user queries in real time.
- Support multi-language queries and synonyms.
- Rank suggestions based on popularity, personalizati...
Capacity Estimation
To estimate capacity, we can start with the following assumptions:
- User Base: Assume Google Search has approximately 3 billion queries per day.
- Typeahead Usage: Let's say 30% of these quer...