Skip to content
BytePatterns

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.

  1. Return the node's precomputed top-10 list
  2. Debounce the keystroke and cancel the request still in flight
  3. Walk the trie down to the node for that prefix
  4. Check the edge cache for this exact prefix first

Mini quiz

1 / 3

Each trie node stores its own top-10 list so that:

New lessons land every few weeks

Leave an address and we will tell you when the next one is up. That is the only reason we will use it.

One address, stored so we can email you. Nothing else, ever.