Design Typeahead
It sounds like a search problem. The twist is the timing. The suggestions have to appear between one keystroke and the next, so each request is answered in tens of milliseconds. The list is ranked by what everyone is searching for right now, a moving target. Those two pulls, a read that has to be instant and a ranking that has to stay current, are what make this more than a database query.
Pin the latency budget before drawing anything, because it decides the shape. People type a few characters a second, so there are roughly 150 to 200 milliseconds between keystrokes. Suggestions need to land before the next key press, or the box feels laggy. Aim well under 100 milliseconds end to end, and realistically the server side gets a few tens of milliseconds. That budget rules out doing any real ranking work when the request arrives. There is no time to scan a list of matches and sort them. The answer for a prefix has to be sitting there already, computed ahead of time, so the read is little more than a lookup.
One more thing to pin early. The data is overwhelmingly read. Almost every interaction is a lookup, and the set of completions changes slowly, on the order of how fast search trends move rather than per request. That skew is the gift this design is built to exploit. Because writes are rare relative to reads and can be batched, you can spend real time building a read-optimized structure offline and then serve it cheaply millions of times.
- 1 diagram
- 4 sections
- about 45 min
Premium lessonAdobe interview guide
These took digging.
What candidates walked out with, from 20,000+ reports, forum threads behind logins and write-ups in Chinese. Then solved step by step.
100 companies. Checked every month.
Unlock all 100 companies$49 a year · less than $1 a week · 30-day money-back guarantee
Adobe interview guideKnow what Adobe asks before you walk in.
20 coding · 4 system design · 22 behavioral questions
Get their questions first.
InterviewLegend is independent and not affiliated with or endorsed by any company it covers.