Whole systems / 6 / 7
Design search autocomplete
Every keystroke in the search box asks for ten suggestions, and the answer must arrive before the next key. We build it step by step: the budget, why `LIKE 'pre%'` fails, a trie with precomputed top-k, prefix shards, debounce and CDN, an offline pipeline with an atomic swap, a real-time layer for trends, filtering and the price of personalization.
- 13 min
- Intermediate
- 12 steps
- Suggest p95
- 60 ms
- Requests to backend
- 3 500 /s
- Freshness lag
- —
- Bad suggestions
- —
- request
- reply
- redelivery
- duplicate
- lost
Numbers are a model scenario, not measurements
The real request
Search box → Suggest APIRequest
GET /suggest?q=ip&lang=en HTTP/1.11
Host: api.example.com
Response
HTTP/1.1 200 OK
{
"q": "ip",
"suggestions": 2[
"iphone 15",
"ipad air",
"ip address lookup"
],
"took_ms": 338
}
q— The prefix typed so far. It changes on every keystroke.suggestions— Ranked completions, most popular first. Ten at most; the UI shows five to eight.took_ms— Server time. It has to stay near 20 ms to fit the 100 ms budget.
Build it yourselfCheat sheetCompare lessons
Course: 74 lessons
01 Foundations
02 Scaling
03 Data & storage
04 Communication
05 Reliability
06 Architecture
07 Security
08 Shipping
09 Whole systems
10 Business processes
11 Case studies