Problem
Member search is the busiest feature of a dating site. In 2012 the Sphinx search code was spread over several places, and results were cached in the user's session.
Replacing it in place could change what millions of members saw on 1,300+ sites, with no easy way back.
What I did
- Started with one model for all Sphinx searches, with its unit tests.
- Built the new search next to the old one instead of editing it in place, so both could run and be compared.
- Covered the new code with unit tests up to 98% before it took any traffic.
- Moved cached results from the session to Memcached, with tags so a profile change clears the cached results that include it.
- Before the switch, went through the old search feature by feature and fixed the gaps. Kept the old one as a fallback for a while, then removed it.
- The comparison also found that sorting by distance was wrong in the old search, so I fixed it in both.
- Also capped the city autocomplete: it could request 10,000+ rows (seen in the internal error logs, never by users). Now it returns 150, without duplicates.
Result
Swipe sideways to see the whole chart →
Stack
- PHP
- Sphinx
- Memcached
- MySQL
- PHPUnit