← All problems
Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Problem 037 · Databases and storage

Design Product Search

Medium 50 min

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
  1. Why is WHERE title LIKE '%boots%' painful over 50 million rows?
  2. How does the index learn about a price change without the seller's request waiting for re-indexing?
  3. Many shoppers type the same popular queries. Is there something cheaper than running them again?

Ready to build?

Open the canvas, place your components and explain your decisions. Your draft saves automatically.

Sign in to start

Failure scenarios

  • A new ranking field needs a full reindexThe team adds a 'sustainability score' to every product and needs it in the index. Re-indexing 50 million products takes about six hours, while 2,000 live updates per second keep arriving.

Run them from the workspace once your design is in place.