Kestrel Trade
- Median latency
- 4.1s to 180ms
- across the top five filters
- Catalog growth
- 100x
- 40k to 4M listings
- Database load
- -64%
- peak CPU
Search that survived a hundredfold catalog
Rebuilt listing search and filtering as the catalog grew from forty thousand items to four million.
Challenge
Search was a set of LIKE queries against the listings table. At three hundred thousand rows the median query passed four seconds and the database spent most of its time on sequential scans.
Approach
- Measured the real query mix instead of the assumed one — 80% of traffic hit five filter shapes
- Moved those shapes to a denormalised read model updated by change events
- Added cursor pagination so deep pages stopped re-scanning from the start
- Kept the old path behind a flag until the new one matched it on a replayed week of traffic
Outcome
Median search latency fell below two hundred milliseconds and stayed there through a hundredfold catalog increase.
- TypeScript
- PostgreSQL
- Redis
- Next.js
