Design a Search Autocomplete System
Last updated: September 4, 2025
Quick Overview
Build a query suggestion system with prefix matching, personalization, trending detection, and strict latency requirements under P99.
Perplexity
September 4, 20257
10
3,860 solved
Build a query suggestion system with prefix matching, personalization, trending detection, and strict latency requirements under P99.
Autocomplete is a key UX feature for search products. This tests real-time data structures and ranking under tight latency constraints.
What the Interviewer Expects
- Design efficient prefix matching with tries or inverted indexes
- Implement trending query detection with decay functions
- Add personalization based on user history
- Meet P99 latency under 50ms
- Blend ML-scored suggestions with rule-based boosting
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 do you handle offensive or dangerous query suggestions?
- How do you cold-start personalization for new users?
- What happens when trending queries spike suddenly?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Data Structure
Use a trie for prefix matching with frequency counts at each node. For scale, shard tries by first character or bigram. Complement with an inverted in...
Ranking and Personalization
Score suggestions by: (1) global popularity (query frequency with time decay), (2) trending boost (recent frequency spike detected via z-score), (3) p...