All system design challenges
#66 Fan-out Search/Fare Caching

Flight Search Engine

Return the cheapest and best flights between two cities in about two seconds, across hundreds of airlines.

Asked at Expedia Skyscanner Google

What is being asked

Design the flight search behind a site like Expedia or Skyscanner. A query is origin, destination, dates and passengers. The answer has to combine fares from airlines and global distribution systems (GDS), including connecting flights, and rank them.

Requirements

Functional

  • One-way, return and multi-city search with filters (stops, airline, times, price).
  • Direct and connecting itineraries.
  • Sort by price, duration or "best".

Non-functional

  • p95 latency around 2 seconds.
  • Supplier queries are slow (1–5 s) and often charged per request.
  • Prices change constantly; a shown price must be re-confirmed before booking.

Design

ClientSearch APIQuery plannerFare cacheGDS adapterAirline API adapterLow-cost carrieradapterMerge + rank
Boxes are services; rounded shapes are data stores and queues.
  1. The query planner first checks the fare cache, keyed by route + date + cabin + passengers.
  2. On a miss (or a stale entry), it fans out to the suppliers that serve that route, in parallel, each with a timeout.
  3. Merge + rank removes duplicates (the same flight sold by two suppliers), builds connections, and scores itineraries.
  4. Results stream to the client as suppliers answer, so the first results appear quickly.

Key decisions and trade-offs

  • Cache with short TTLs per route. Popular routes (Mumbai–Delhi) are searched thousands of times an hour; caching them for a few minutes cuts supplier cost and latency hugely. Rare routes go live.
  • Pre-compute connections. Building every A→X→B combination at query time is expensive; a nightly job pre-computes valid connection points and minimum layover times per airport.
  • Streaming vs waiting. Showing results as they arrive feels fast, but the list reorders. Many sites show a progress bar and settle after a few seconds.
  • Look-to-book economics. Supplier calls cost money; cache hit rate is a business metric, not just a latency one.

Follow-up questions

  • How do you detect that a cached fare is wrong before the user clicks "book"?
  • How do you search "flexible dates ±3 days" without 7× the supplier calls?
  • How would you rank "best" rather than "cheapest"?
  • One GDS is down for an hour. What changes?
Log in to tick off the challenges you have worked through. Log in