An online marketplace sells 50 million products from 200,000 sellers. Shoppers type queries like 'waterproof hiking boots', filter by brand, size, price and rating, and expect results in a fraction of a second, with counts next to each filter. Sellers change prices and stock constantly, about 2,000 product updates per second, and a product that sells out should stop appearing near the top within a minute. Peak search traffic is 8,000 queries per second.
Functional requirements
Full-text search over product title, description and attributes, with typo tolerance
Filter by category, brand, price range, rating and availability
Show facet counts for each filter value
Sort by relevance, price or newest
Reflect price and stock changes in results
Non-functional requirements
Search responds in under 200 ms at p95
Catalogue changes appear in search within 60 seconds
Search stays available when the catalogue database is down
Relevance can be tuned without re-indexing everything
Constraints and scale
50 million products, about 5 KB of indexed text and attributes each
8,000 search queries per second at peak
2,000 product updates per second, mostly price and stock changes
You will practise
Use an inverted-index search engine for full-text and faceted search instead of SQL LIKE queries
Keep a search index in sync with the source of truth through change events
Shard and replicate an index for size, throughput and availability
Show 3 hints
Why is WHERE title LIKE '%boots%' painful over 50 million rows?
How does the index learn about a price change without the seller's request waiting for re-indexing?
Many shoppers type the same popular queries. Is there something cheaper than running them again?