Design Search Autocomplete
System Design Cases: lesson 6 of 20
Not a search — a walk down a path somebody built last night.
Lesson 6 of 20 · 6 min
Design Search Autocomplete
Step 1 of 11
Ten thousand queries a second, and every keystroke is a candidate request. Cut them first.
The Idea
Turn each keystroke into ten ranked suggestions inside 100 ms. Assume 10 000 queries a second at peak over 50 million distinct prefixes — far too tight to run a real search and rank it while somebody is still typing.
Real-World Example
A library's card drawer. The tabs already sort the cards, so you are not searching at all: you are walking down a path that somebody else built and sorted in advance.
The Tradeoff
A trie whose nodes carry their own top-10 answers a prefix in one lookup, and must be rebuilt as popularity shifts, so suggestions lag by however long that job takes. Debouncing on the client and caching at the edge delete most of the traffic before it ever exists.
Your turn
Put the steps in the right order.
- Return the node's precomputed top-10 list
- Debounce the keystroke and cancel the request still in flight
- Walk the trie down to the node for that prefix
- Check the edge cache for this exact prefix first
Mini quiz
1 / 3