Design Search Autocomplete

Normal 3
SearchRead-HeavyCaching

Design search autocomplete for a large shopping site. As a user types into the search box, the top 10 suggested queries appear under it, updated on every keystroke.

Functional:

  • Return the top 10 suggestions for the typed prefix, ranked by popularity.
  • Reflect trending searches within an hour (a viral product should show up fast).
  • Support the site's 12 languages.
  • Remove offensive or blocked suggestions immediately when policy asks.

Non-functional:

  • Suggestions under 50 ms at p99, measured at the server.
  • Handle every keystroke of every user at peak.
  • Stay up when the ranking pipeline is down, with slightly stale suggestions.
  • 100 million daily users; peak 300,000 keystroke requests per second.
  • 50 million distinct past queries; prefixes up to 30 characters.

The search results page, spell correction, and personalization.

System design
Loading editor...