Latest / The CTO Podcast with Fexingo: Technical Leadership, Architecture, and Engineering Org / How Airbnb Rebuilt Search for 150 Million Guests
Transcript
- Lucas: So Airbnb runs roughly 150 million searches a night. That's not a typo. Every single one of those needs to return relevant listings in under 200 milliseconds, and they do it with a custom search stack built on top of Elasticsearch. But it wasn't always that way. Luna: Right, they started with a pretty straightforward Postgres setup, didn't they? I remember hearing that before they rebuilt, searches could take nearly a second. Lucas: Exactly. Before the migration, a typical search took about 800 milliseconds on average, and that was already after years of optimization. The problem was the data model. Airbnb stored listings as rows in Postgres, with dozens of columns for price, location, amenities, availability, host status — you name it. Every search query would generate a SQL statement with multiple joins and subqueries. It worked fine when the platform had 50,000 listings, but by 2015 they had over 2 million active listings worldwide. Luna: And the queries weren't just simple keyword matches either. Guests filter by price range, number of bedrooms, superhost status, instant book, pet-friendly — there's a combinatorial explosion of filter combinations. Lucas: Exactly. The engineering team calculated that there were over 10 million possible filter combinations. Each one required a different query plan. Postgres's query planner would sometimes pick a bad plan for edge-case filters, and suddenly a search that took 200 milliseconds would spike to three seconds. For a consumer-facing booking platform, that's a conversion killer. So in late 2015, the search team — which was about 12 engineers at the time — started a project internally called "Search Quality Next." Luna: I like that. Not exactly catchy, but very internal. So they decided to move to Elasticsearch. What was the core architectural decision? Lucas: The core decision was to invert the data model. Instead of storing listings as rows and querying with joins, they'd index each listing as a denormalized document in Elasticsearch. Every document contains all the fields that could be used for filtering or ranking — price, location coordinates, amenity flags, review scores, host metrics — all pre-joined at indexing time. That way, a search query is a single lookup against the index, no joins needed at query time. Luna: But denormalization has a cost. You have to keep all those documents in sync when something changes. If a host updates their price, you need to reindex that document instantly. Lucas: Right, and Airbnb solved that with a change data capture pipeline. Every time a listing attribute changes in Postgres, a Kafka event fires, and a consumer updates the corresponding Elasticsearch document within seconds. They also built a two-phase ranking system on top of the search index. Phase one is a fast, lightweight filter and score pass that runs on every shard in the cluster. It uses a few hard constraints — like minimum price or location bounding box — and a simple scoring function based on price, distance, and review count. That phase returns the top 500 candidates per shard. Luna: And phase two? Lucas: Phase two is a centralized ranker that collects the top candidates from all shards — usually around 2,000 to 5,000 documents — and applies a more sophisticated machine learning model. That model considers dozens of features: booking probability, guest preferences from past trips, seasonal trends, even the time of day. The model is lightweight enough to run in under 20 milliseconds per query. That two-phase architecture is what lets them hit that 200-millisecond hard target at peak. Luna: And the team structure — how did they organize around this? I imagine you can't just throw a dozen engineers at a search rewrite and hope for the best. Lucas: They actually structured it as a temporary strike team within the infrastructure org, reporting directly to the VP of Engineering. The team had three sub-groups: one focused on the Elasticsearch index and query pipeline, one on the machine learning ranking model, and one on the experimentation framework. The experimentation piece was critical because they ran parallel searches — old Postgres and new Elasticsearch — for months, comparing results and iterating on relevance metrics. Luna: That's the kind of thing that listeners who build revenue-critical systems will appreciate. You don't flip a switch. You shadow-run for a long time. Lucas: Exactly. They ran both systems in production for six months, with the new search serving a gradually increasing percentage of traffic. They also built a "search quality dashboard" that tracked metrics like booking conversion rate, average session length, and user-reported issues. One metric that surprised them: after the new search fully rolled out, the average number of filters applied per search dropped by 15 percent. Because the ranking was better, guests didn't need to narrow results as aggressively. Luna: So better search quality actually simplified the user experience. That's a great outcome. But there must have been cultural challenges too. Was there resistance from product teams who were used to the old search behavior? Lucas: Absolutely. The biggest pushback came from the growth and marketplace teams, who had dashboards and automated tools that queried the old search directly. They relied on consistent, predictable behavior. The new ranking model was a black box in comparison. The search team had to build an explainability layer — essentially a debug endpoint that showed why a specific listing ranked where it did for a given query. That transparency helped the product teams trust the system. It was actually a masterclass in internal stakeholder management. Luna: It's a great story about building not just the right technology, but also the right organizational trust. And I think that's part of what makes these conversations valuable for people who are building or running technical teams. If you're listening and this kind of content helps you think through your own architecture or org decisions, we deliberately don't run ads on these episodes. If you want to support that choice, the link is buy me a coffee dot com slash fexingo. No pressure, just putting it out there. Lucas: Yeah, and it's because we think the content should speak for itself. Okay, back to the search story. One of the most interesting technical trade-offs they faced was around geographic ranking. Airbnb's old system ranked listings primarily by distance from the search center point. The new system realized that travelers often care more about neighborhood character than sheer proximity. So they built a "neighborhood relevance" feature that boosted listings in areas that matched the search query's implied vibe — like "trendy" or "family-friendly" — even if those listings were slightly farther away. Luna: That sounds like a hard modeling problem. How did they even define a neighborhood's vibe in a way a machine could learn? Lucas: They used a combination of listing metadata and user behavior. For example, if a user searches for "arts district" and then books a listing in a certain area, that's a signal. They also took the text of guest reviews and ran topic modeling to cluster neighborhoods by keywords. The result was a set of neighborhood embeddings that fed into the ranking model. It increased booking conversion by about 4 percent in the first quarter after launch. Luna: And all of this runs on Elasticsearch. Did they run into any scaling issues with the cluster itself? Lucas: They did. By 2018, the Elasticsearch cluster was handling over 100 million queries a day across multiple data centers. They had to shard by geographic region to keep the index size manageable — essentially one cluster per continent. They also had to tune the refresh interval carefully. Elasticsearch by default refreshes indices every second, but for a search that doesn't need real-time freshness, they set it to 30 seconds. That cut indexing load by a huge margin. Luna: Thirty seconds sounds like a lot for a booking platform. What about availability — if a host changes price to "available tonight" at a discount, thirty seconds could mean a missed booking. Luna: They compensated with a separate "instant availability" index that refreshed every five seconds for listings that had the "Instant Book" feature. That way, high-intent queries got fresher data without burdening the main index. It's a great example of tiered data freshness. Lucas: Exactly. And the key takeaway I think for anyone building search is that you don't need to be perfect for every edge case on day one. Airbnb's team started with a simple two-phase approach, got it to 200 milliseconds, then layered on machine learning, explainability, neighborhood embeddings, and tiered freshness over time. The architecture evolved with the product. Luna: And I think that's the lesson that sticks with me. The best technical decisions aren't the ones that are perfect upfront — they're the ones that leave room to add complexity later as you learn what matters. For Airbnb search, that meant starting with a solid denormalized index and a simple ranking function, then building the ML layer once they had enough data to train it properly. Lucas: Right. And now, seven years later, that same architecture handles 150 million searches a night, with latency under 200 milliseconds and a booking conversion rate that's measurably higher than the old system. Not bad for a strike team of twelve engineers. Luna: Not bad at all. And with that, I think we've covered the core architecture and the organizational story. Next time, we'll look at how Airbnb handled the machine learning model lifecycle — specifically how they retrained and deployed ranking model updates without disrupting search quality. Lucas: Looking forward to it. And as always, thanks for listening.