~learn.
0:00 / 1:13
W07 · Typeahead

You searched once. The server heard twelve times.

transcript

You searched once. The server heard it twelve times. Because every letter you type sends its own request.

A store with 10 million daily users. Each runs 8 searches a day. At a peak of three times the average, that's about 2,800 searches a second.

The search cluster was built for 10,000 a second. Plenty of room, right? Now add typeahead. Each search is about 12 keystrokes. One request each. That's 33,000 requests a second. Over three times the cluster.

Make each keystroke a prefix query on that cluster, and it drowns. Not just the dropdown. Search slows down for everyone in the store.

The fix starts on the phone. Wait for a short pause in typing. Cache every prefix. About 11,000 a second reach the CDN. 60 percent are answered there. About 4,400 reach the origin. And there, it's a lookup in memory. Not a search.

Typeahead isn't a smaller search. It's a different system. A precomputed list for every prefix, read from memory.

Full breakdown in the lecture.