Design a Search Autocomplete System at TikTok Scale
Last updated: March 3, 2025
Quick Overview
Build typeahead suggestions with prefix matching, personalization, trending detection, and sub-100ms latency for billions of daily queries.
ByteDance
March 3, 20259
3
4,297 solved
Build typeahead suggestions with prefix matching, personalization, trending detection, and sub-100ms latency for billions of daily queries.
Standard but scaled to ByteDance's volume. Tests data structure choice and ranking under tight latency constraints.
What the Interviewer Expects
- Design efficient prefix matching with tries or inverted indexes
- Implement trending query detection
- Add personalization based on user history
- Meet sub-100ms P99 latency
- Handle offensive query filtering
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 multi-language autocomplete?
- How do you detect and suppress dangerous search suggestions?
- What is your cold-start strategy for new users?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Architecture
Shard a trie index by language and first character. Each shard fits in memory (~2GB for the English trie). Serve from the nearest region. Cache the to...
Ranking
Score suggestions by: global popularity (exponentially decayed frequency), trending boost (z-score of recent frequency vs. baseline), and personalizat...