Design Amazon Search Autocomplete Ranking

Free with account Updated Nov 16, 2026 · 17 min read
On this page

    Problem Description

    In this interview, we're going to design the ranking behind the suggestions an online store shows under its search box while a shopper types, similar to the suggestions in Amazon's or eBay's search bar. As the shopper types each letter, such as "st", the box shows up to 8 complete searches, such as "stroller" or "standing desk". The system decides which searches to suggest and in what order, so the one this shopper means comes first, using what they searched for and looked at before, even after only a letter or two. When something suddenly becomes popular, such as a newly released game, it starts appearing as a suggestion. Suggestions never include harmful phrases or searches that return nothing. The system keeps learning from which suggestions shoppers pick. You can use existing building blocks: the store's search service, which runs every search and already records every search, product view and purchase in the store's event stream, and a safety classifier model that labels a phrase as safe or unsafe. This interview is about choosing and ordering suggestions, not about the search results.

    Not the same as Design a Typeahead System, which is about storing and serving the most popular completions for every prefix.

    Out of Scope

    • Suggesting products or categories directly – the list only holds searches; a good follow-up question.
    • The search results page – the search service ranks results.
    • Spelling correction of the typed letters – a separate system; we complete what was typed.
    • Writing the safety policy and training the classifier – the trust and safety team owns both; we use the classifier's labels and their blocked phrases.
    • Many languages per country – one main language per country to start.

    Good Clarifying Questions

    1. How many searches, and how often does the app ask for suggestions? – About 200M searches a day. The app asks after each short pause in typing, about 6 times per search: 1.2B requests a day, about 40,000 a second at peak.
    2. What does a good suggestion achieve? – Shoppers type less and still reach a search that ends in a click or a purchase. Suggesting popular searches that lead nowhere is a failure.
    3. How fast must suggestions appear? – Within 100 ms of the pause on the phone at p99, which leaves about 20 ms on our servers and a few milliseconds for the model.
    4. How fresh must they be? – What the shopper searched for or looked at in this visit should shape the next suggestions within seconds. A search that is suddenly popular should appear within 15 minutes. The model is retrained daily.
    5. What if suggestions fail? – The search box must keep working; shoppers can always type their whole search. Suggestions are allowed to disappear, never to block typing.

    Requirements

    Functional Requirements

    1. Suggest Searches as They Type – As shoppers type, they see up to 8 complete searches, the one they most likely mean first, including their own past searches and searches that are suddenly popular.
    2. Keep Bad Suggestions Out – Suggestions never include a phrase the safety classifier labels unsafe or the trust and safety team blocked, or a search that returns no results.
    3. Record What Shoppers Pick – The system records which suggestions each shopper was shown, in which position, which one they picked or what they searched instead, and whether that search ended in a click or a purchase.
    4. Keep Learning – The system trains a new model from these records daily and uses it only after it proves at least as good as the current one.

    Non-Functional Requirements

    1. Scale – 200M searches × 6 requests = 1.2B suggestion requests a day: about 14,000/s on average, 40,000/s at peak.
    2. Latency – Suggestions on screen within 100 ms at p99; about 20 ms on our servers, a few ms for the model.
    3. Freshness – The shopper's own searches and views shape suggestions within seconds; a suddenly popular search appears within 15 minutes; a new model daily.
    4. Availability – 99.9%. If the model fails, suggestions come in popularity order; if suggestions fail, the search box still works without them.