System design

Intermediate

Search without melting the database

A second-hand marketplace added a search bar. A third of all reads are now text searches with LIKE queries, and the database is on its knees.

A LIKE '%word%' query scans the whole table: it costs about 25 times a normal read. New listings should appear in search within seconds.

What your design must achieve

  • Availability ≥ 99.9 %
  • Latency p99 < 250 ms
  • Stale reads < 2 %
  • Infrastructure cost per month < 6,000 $ bonus

What you will master