Search Autocomplete
Suggest as they type — in under 100 milliseconds, every keystroke.
Return suggestions in well under 100ms while a query trends and nodes fail.
Every keystroke is a request, so the read path must be brutally fast: cache the top prefixes and keep the suggestion index hot. The trie is built offline from query logs.
Components in play
- API Gateway — Terminates and routes keystroke requests.
- Suggest service — Ranks and returns top completions for a prefix.
- Top-query cache — Serves the hottest prefixes from memory.
- Suggestion index — Prefix / trie index of candidate queries.
Graded on these SLOs
- ≤ 80 msSuggestion p99
- ≥ 98.00%Suggestions return
- ≥ 15k rpsCarry the typing
- ≤ 90%Headroom
The brief
Design the autocomplete behind a search bar: as the user types each character, return the top-ranked completions almost instantly. Reads are enormous and latency-critical; the ranked suggestions are computed offline from what everyone searches.
Functional
- Return top-k completions for a prefix
- Rank by popularity / recency
- Update suggestions from real query traffic
Non-functional
- End-to-end latency well under 100ms
- Massive read volume (every keystroke)
- Eventually-fresh suggestions are fine
Read the deep dive
15 min readAutocomplete is the rare system where the latency budget is shorter than human reaction time. The suggestion list has to repaint between one keystroke and the next, which means the server has tens of milliseconds, not hundreds, and it pays that cost on every single character a user types. The volume is brutal precisely because it is keystroke-level: a search bar fielding a few thousand queries per second is answering tens of thousands of completion requests per second. What makes this tractable is that the hard work and the fast work are completely separable. Ranking which completions are good is an expensive, data-heavy computation over everyone's search history, but it does not need to be fresh to the second. Serving the answer for a prefix is a trivial lookup, but it has to be instant and survive nodes dying mid-spike. So the whole design is an exercise in pushing all expensive computation offline and making the online path do nothing but read from memory. This guide walks you to that design from first principles, with the numbers that justify each choice, calibrated to a chaos simulator whose targets are p99 under 80ms, availability at or above 98%, sustained throughput of 15,000 requests per second, and peak saturation no higher than 0.9.
Warm-up: design decisions
Optional theory to prime the calls a senior engineer would make before you build.
Solving is a Pro feature
Unlock the on-canvas AI design coach, per-run design reviews, the chaos simulator and all 12 problems for $15/month.
- AI design coach on your canvas — pins failure points & over-engineering
- Honest AI design review on every run
- All 12 problems + unlimited chaos simulator
- Points, levels & leaderboard