SevyDevy

Flight Search System Design: Fare Caching and Why Fares Vanish at Checkout

, Last updated , 20 min read

Summary

  • Flight search system design is about showing fares you do not own: a travel site asks outside suppliers, such as airline systems, for prices, then caches and re-checks them.
  • Fares change and seats sell out while a user types. So every booking runs a price check, a fresh call to the supplier that confirms the price before payment.
  • A fare cache keeps recent search answers for a short TTL (time to live, how long an answer counts as fresh). It saves supplier calls but makes shown prices older.
  • The look-to-book ratio is searches per booking. Suppliers limit and watch it, because answering millions of searches costs them money and most never become bookings.
  • Beginners can stop after the checkout section. Engineers get a runnable simulation showing how TTL trades supplier calls against price checks that do not match, and why booking calls need their own rate-limit lane.

What goes wrong when a flight search shows fares you cannot book?

The user picks a fare, fills in names and card details, and then the site says the price went up or the flight is gone. That moment loses trust and often the sale. In flight search system design, this failure is the central problem to plan for, not a rare bug.

Picture a common setup. A travel site in India sells domestic flights, such as Delhi to Mumbai, but owns no seats at all. It asks outside suppliers for every price. The setup is made up, but the checkout failure is real. The site gets about 5 searches a second, around 4.3 lakh (430,000) a day.

Its supplier contract allows far fewer calls than that, say 1 call a second (made up). About 1 search in 150 turns into a booking attempt. A user spends 2 to 15 minutes on the passenger form. This guide follows that one site from search box to confirmed order.

You need six words: supplier, offer, fare cache, TTL, price check and look-to-book ratio. Each one gets a plain meaning and an example from the running site.

  • Supplier: the outside system that owns the seats and prices. It can be a GDS (global distribution system, a large shared booking network airlines publish fares to) or an airline's own API. The site calls it for every fresh price.
  • Offer: one priced option the supplier returns, such as two flights on 20 December for 5,400 rupees. Many APIs give each offer an ID and an expiry time.
  • Fare cache: the site's own short-term store of recent search answers, so a repeat search can skip the supplier.
  • TTL: time to live, the number of seconds a cached answer counts as fresh. After that it is stale, meaning too old to trust without asking again.
  • Price check: a call made at booking time that asks the supplier to confirm the chosen offer's current price and availability. People also call it repricing.
  • Look-to-book ratio: how many searches happen for each booking. A ratio of 150 to 1 means 150 searches for every booking.

Flight search system design is planning a service that answers fare questions fast while the real prices live in someone else's system. Speed comes from caching and parallel calls. Correctness comes from a final price check against the supplier.

A hotel booking system often searches inventory it holds or syncs by date. A flight site usually holds nothing. Its fares come from suppliers that compute them on request, and those answers start ageing the moment they arrive.

So the design splits into two paths with different rules. The search path is huge in volume and may show slightly old prices. The booking path is small in volume and must never charge a price the supplier has not just confirmed.

Two paths: cheap search, careful booking

Notice that only the booking path talks to the supplier every time. The search path goes through the cache first, and both paths share one rate-limited gateway.

Diagram connections:

  • Traveller's app to Search service (search)
  • Search service to Fare cache (fresh entry?)
  • Fare cache to Supplier gateway (on a miss)
  • Traveller's app to Booking service (book this offer)
  • Booking service to Supplier gateway (price check, order)
  • Supplier gateway to GDS supplier (shop or price)
  • Supplier gateway to Airline NDC API (shop or price)
  • Booking service to Payment provider (charge)
  • Traveller's app: Searches many times, books rarely
  • Search service: Builds result lists, sorts and filters
  • Fare cache: Recent answers per route and date, short TTL
  • Booking service: Price check, then order and payment
  • Supplier gateway: Counts calls, applies rate limits, retries
  • GDS supplier: Shared booking network for many airlines
  • Airline NDC API: Airline's own offers and orders
  • Payment provider: Final payment only after the order is confirmed

Why do fares vanish or change at checkout?

Fares vanish because the price the user saw was a snapshot, and the airline kept selling seats after it was taken. By the time the user pays, that fare class may be sold out or repriced.

Airlines sell the same seats through many channels at once. Prices move as seats sell and as airline pricing rules react. Your site sees none of that until it asks again.

Supplier docs say this plainly. The Duffel API reference for offers states that search prices returned by airlines are not guaranteed to be available at the time of booking. It tells developers to fetch the single offer again and book with the latest data.

There are three separate sources of age, and they add up:

  • Cache age: the answer may have sat in your fare cache for up to one TTL before this user saw it.
  • Form time: the user then spends minutes on names, seats and payment details.
  • Offer expiry: many suppliers stop accepting an offer after a deadline, even if nothing else changed.

An everyday picture helps. A cached fare is like a phone photo of a vegetable stall's price board. The photo is quick to share, but the seller charges today's board price. Where the picture breaks: a stall rarely runs out, while a cheap fare class often sells out completely.

For engineers

Beginners can stop here. You now know the core idea: search shows recent snapshots, and booking confirms the live price. The sections below cover cache TTLs, supplier limits, the price check step and a runnable simulation.

How does a fare cache with a TTL work?

A fare cache stores each search answer under a key, such as origin, destination, date and passenger count. Any repeat search within the TTL is answered from the cache, and the supplier is not called.

This follows the same idea as HTTP caching. RFC 9111, the HTTP caching standard, defines a response's age as the time since the origin made it. A response is fresh while its age is under its freshness lifetime, and stale after.

RFC 9111 also says a cache must not serve stale responses unless it is disconnected or the client or origin allows it. A fare cache is your own application code, not an HTTP cache. Still, the same honesty rule is a good default: label old fares instead of hiding their age.

What goes in the cache key

The key must hold everything that changes the answer. For the running site that is origin, destination, travel date, cabin and passenger mix. Two adults and one child get different offers from one adult, so they need different keys.

Which TTL fits which search

At 5 searches a second, the running site's popular routes are searched again within seconds, so even a short TTL saves many calls. Not every search needs the same freshness, either. A 2019 report commissioned by IATA, the global airline trade body, suggests caching for travellers in an inspirational phase, such as far-off trips with no fixed date.

What is the look-to-book ratio, and why do airlines care?

The look-to-book ratio is the number of searches for each booking. Airlines care because each search costs them computing power, while only bookings earn money.

That 2019 IATA report gives a sense of scale. It reports 100- to 300-to-1 on airlines' own websites. For online travel agencies and metasearch sites, which compare prices from many sellers, it reports 1,000-to-1 at best and commonly above 10,000-to-1.

The same report says robots are believed to generate a significant share of shopping requests. It advises airlines to monitor shopping volumes per seller, and advises agencies to watch their look-to-book ratios with airline partners. Those numbers are from March 2019, so treat them as a scale, not a current benchmark.

For the running site, 150 searches per booking attempt is its own user-side ratio. What the supplier sees depends on the cache. With no cache, every search becomes a supplier call. With a 5-minute TTL, the simulation below cut supplier search calls by about 88 percent compared with sending every search on.

How do you pick a cache TTL for fares?

You pick the TTL by measuring two things at once: supplier calls saved and price checks that do not match the shown fare. A longer TTL cuts more supplier calls but leaves more checks not matching.

To see the trade-off, we wrote and ran a small Python simulation of the running site. It modelled 300 route and date keys with uneven popularity, 5 searches a second for six hours, and a supplier limit of 1 call a second. All inputs are made up.

Each fare changed on average every 30 minutes, and 15 percent of changes sold out the shown offer. Booking users took 2 to 15 minutes on the form. When the limit blocked a search, the site showed the last stored fare, labelled as old, or an error if it had none.

The run used Python 3.13.18 and fixed random seeds, so it prints the same table every time. TTL 0 means every search tries the supplier first.

Six simulated hours, about 108,000 searches and 740 booking attempts (all inputs made up). Match, rise and gone shares are of price checks that reached the supplier.
SetupCache hitsSupplier search callsPrice checks that matchedPrice roseOffer gonePrice checks blocked by 429
TTL 0, no supplier limit0%108,13872.3%13.2%7.3%0
TTL 0, 1 call a second0%21,46262.2%18.6%9.6%576 of 732
TTL 60 seconds65.2%21,17171.8%12.3%8.3%331 of 739
TTL 5 minutes87.9%12,83867.8%15.0%9.1%8 of 743
TTL 15 minutes94.5%5,82255.7%21.3%12.4%0
TTL 30 minutes96.9%3,29245.2%24.8%15.7%0
TTL 60 minutes98.3%1,78126.2%34.3%22.9%0

Three lessons come out of the table. First, in this model, even live search with no limit left 27.7 percent of price checks not matching the shown fare. Form time alone is enough for fares to move.

Second, with TTL 0 the supplier limit is the real problem. One call a second allows only 21,600 calls in six hours, so the TTL 0 and 60-second rows both hit that ceiling.

Search traffic used up the budget, and 576 of 732 booking price checks were rejected with HTTP 429, the status code for too many requests. Another 1,205 searches got an error page.

Third, the useful TTL zone is short. In this model, 5 minutes cut supplier search calls by 88 percent, and 67.8 percent of checks matched against 72.3 percent with live search. At 60 minutes, only 26.2 percent matched.

Your real numbers will differ, because they depend on route popularity and how fast your suppliers' fares move. The method carries over. Log every price check outcome per route, then shorten the TTL where mismatches climb.

How does the price check at booking work?

The price check sends the chosen offer back to the supplier and asks for its current price and availability. The site books only if the answer matches, or if the user accepts the new price.

Both supplier APIs we checked expose this step. In the Amadeus Self-Service API specification, Flight Offers Price takes a list of flight offers. Its own summary is to confirm pricing of given flight offers. Duffel's equivalent is the Get a single offer call.

Duffel's help centre recommends running that refresh before showing the passenger form, not after. The user then learns about a change before typing every name and card number.

  1. Show search results

    Serve results from the fare cache or a fresh supplier call. Keep each offer's ID, price and the time it was fetched.

  2. Refresh when the user picks

    Call the supplier's single-offer or pricing endpoint for that one offer. Compare the live total with the shown total.

  3. Handle the three outcomes

    Same price: continue. New price: show old and new prices and ask. Gone: say so and offer to search again.

  4. Price check again just before payment

    If the form took long, refresh once more. Respect the offer's expiry time if the supplier gives one.

  5. Create the order with the confirmed offer

    Send the latest offer data, not the cached copy. Take the final payment only after the supplier confirms the order; a card hold before that is fine.

  6. Record the outcome

    Log matched, rose, fell or gone, with route and cache age. These logs tell you whether your TTL is too long.

The price check decision at booking

Notice that the card is charged only on the matched path. A changed price goes back to the user, and a gone offer goes back to search.

Diagram connections:

  • User picks an offer to Price check call (refresh offer)
  • Price check call to Same price? (live answer)
  • Same price? to Create order (Yes)
  • Same price? to Show the new price (No, new price)
  • Same price? to Search again (No, offer gone)
  • Show the new price to Create order (accepted)
  • Create order to Charge the card (confirmed)
  • User picks an offer: Shown price came from cache or search
  • Price check call: Booking service → supplier
  • Same price?: Compare live total with shown total
  • Show the new price: User accepts or goes back
  • Search again: Fresh supplier call, cache entry replaced
  • Create order: Booking service → supplier
  • Charge the card: Only after the order is confirmed

What do flight APIs document about offer expiry and price changes in 2026?

They document expiry times, price-change errors and ticketing deadlines, and the details differ by supplier. The table lists what two public API references say, as of 30 October 2026.

What two flight API references document, as of 30 October 2026
TopicDuffel APIAmadeus Self-Service spec
Search callCreate an offer request with passengers and slices (one per direction of travel)Flight Offers Search v2.9.1, up to 250 offers per request
Price check callGet a single offer, for up-to-date informationFlight Offers Price v1.3.0, confirms pricing of given offers
Time limits on an offerEach offer has expires_at; help centre says usually about half an hourlastTicketingDate: ticketing deadline if booked the same day as the search
Price changed at bookingprice_changed error, HTTP 422Flight Create Orders v1.10.0 error 37200, PRICE DISCREPANCY
Seats could not be sold at bookingoffer_no_longer_available error, HTTP 422Flight Create Orders v1.10.0 error 34651, SEGMENT SELL FAILURE
Too many callsrate_limit_exceeded, HTTP 429, retry after the given timeNot covered in these three spec files

Two details are easy to miss. Duffel's supplier_timeout setting caps how long it waits for each airline during a search. As of 30 October 2026, it defaults to 20 seconds and accepts 2 to 60 seconds.

The Amadeus booking spec also has a price margin field marked for the book step only. It sets the percentage up or down a booking can tolerate, and 0 means no difference is tolerated.

Amadeus archived its Self-Service API specification repository on 17 July 2026, and it is now read-only. The spec files are still readable, which is why we cite them. Check your supplier contract for the API you actually use.

How do you protect the booking path from rate limits?

Give booking calls their own reserved share of the supplier call budget, so searches can never use it up. Then handle HTTP 429 answers on the search path by serving labelled cached fares or a clear retry message.

Supplier APIs can reject calls when you send too many. Duffel, for example, documents a rate_limit_exceeded error with HTTP 429 that asks you to retry after the time it gives. A shared limiter puts every search and every booking in one queue.

The simulation showed why that hurts. With TTL 0 and one shared limit, 576 of 732 booking price checks were blocked. We then split the same 1 call a second into 0.8 for search and 0.2 reserved for bookings. Only 10 of 731 price checks were blocked. The cost was more search errors, 1,419 instead of 1,205.

  • Separate lanes: one token bucket for search, a small reserved one for price checks and orders. A token bucket is a counter that refills at a fixed rate and allows one call per token.
  • Back off on 429: wait the time the supplier asks for, and do not retry searches in a tight loop.
  • Collapse duplicates: if ten users miss the cache on the same key at once, send one supplier call and share the answer.
  • Shed low-value searches first: date-flexible or far-off searches can wait or use older cached answers.

What changes with NDC offers and orders?

NDC, short for New Distribution Capability, is an IATA programme that moves airline selling towards offers and orders that the airline itself creates. IATA describes NDC as an XML-based data transmission standard based on offer and order management processes.

In practice, the airline builds an offer on request, with its own price and extras, and then holds the confirmed purchase as an order. IATA's ONE Order initiative aims to replace separate booking, e-ticket and extra-services records with one customer-focused order record.

For your design, NDC raises the stakes on caching. Offers can be personalised per request, so a shared cache can show the wrong offer to the wrong user. The IATA report notes that third-party caches tend to contradict the idea of personalised offers.

The same report says caches can trigger unproductive shopping calls just to stay fresh. It also says caching only cuts cost when request volumes are high enough. Our advice, not the report's: cache popular, generic searches, and send personalised or loyalty-linked searches straight to the airline.

How do you test a fare cache and price check before launch?

Test with a fake clock and fake supplier answers, so you can move time forward and force each outcome. This small Python sample shows a TTL cache and the three-way price check.

python
import time


class FareCache:
    def __init__(self, ttl_seconds, clock=time.monotonic):
        self.ttl, self.clock, self.store = ttl_seconds, clock, {}

    def get(self, key):
        hit = self.store.get(key)
        if not hit:
            return None
        remaining = self.ttl - (self.clock() - hit["at"])
        # max() turns zero or negative time left into 0, which means stale
        return hit["fare"] if max(remaining, 0) else None

    def put(self, key, fare):
        self.store[key] = {"fare": fare, "at": self.clock()}


def reprice(shown, live):
    if live is None:
        return "GONE: offer sold out, show other flights"
    if live["price"] == shown["price"]:
        return "OK: book at the shown price"
    return f"CHANGED: was {shown['price']}, now {live['price']}, ask the user"


now = [0.0]
cache = FareCache(ttl_seconds=300, clock=lambda: now[0])
key = ("DEL", "BOM", "2026-12-20", 1)
cache.put(key, {"offer": "fake-offer-1", "price": 5400})

now[0] = 120
print("t=120s cache:", cache.get(key))
now[0] = 301
print("t=301s cache:", cache.get(key))

shown = {"offer": "fake-offer-1", "price": 5400}
print(reprice(shown, {"offer": "fake-offer-1", "price": 5400}))
print(reprice(shown, {"offer": "fake-offer-1", "price": 5830}))
print(reprice(shown, None))

Running it with Python 3.13.18 prints the cached fare at 120 seconds and None at 301 seconds, because the TTL is 300. The three price check lines print OK, CHANGED with 5,400 and 5,830, and GONE.

Beyond unit tests, replay a day of real search logs against a copy of the cache. Count hits, supplier calls and simulated mismatches per TTL before changing production settings.

In the interview

How do you explain flight search system design in a system design interview?

Explain it as two paths with different promises: a cheap, cached search path and a strict, always-checked booking path. Then show how supplier limits shape both.

  1. Clarify scope and numbers

    Ask about searches per second, bookings per day and supplier call limits. Work out the look-to-book ratio early.

  2. Draw the two paths

    Search goes through a fare cache and a supplier gateway. Booking goes through a price check, order creation and payment.

  3. Design the cache

    Name the key fields and a short TTL. Explain how popular routes and far-off dates change the choice.

  4. Protect the supplier budget

    Reserve a lane for booking calls, back off on HTTP 429 and collapse duplicate misses.

  5. Handle the price check outcomes

    Matched, changed or gone, each with clear user messaging. Charge only after the order is confirmed.

  6. Measure and tune

    Track cache hit rate, supplier calls per booking and price check mismatches per route. Tune the TTL from those.

Questions people ask

Why does the flight price change when I click book?

The price you saw was a snapshot, and the airline kept selling seats after it was taken. The site may also have shown a cached answer a few minutes old. At booking, it asks the supplier again, and the live price can differ. Good sites show both prices and let you decide.

Can a travel site cache flight prices at all?

Yes, as long as it treats cached prices as estimates and checks the live price before charging. A short TTL on popular routes saves many supplier calls. The booking step must still confirm the offer with the supplier, because the cached price can be wrong by then.

What is a good look-to-book ratio for a flight site?

There is no single good number; it depends on the channel and your supplier contract. A 2019 IATA-commissioned report gave 100- to 300-to-1 for airlines' own websites and often above 10,000-to-1 for online agencies and metasearch. Agree a target with each supplier and track it daily.

What is the difference between an offer expiring and a fare changing?

An offer expiring is a deadline the supplier sets, after which that offer ID cannot be booked at all. A fare changing means the airline's price moved, even before the deadline. Duffel's help centre says its offers usually last about half an hour. A price can still change inside that window.

Should the price check happen before or after the passenger form?

Do it before the form, and again just before payment if the form took long. Duffel's help centre recommends refreshing the offer before showing the passenger form, so users learn about changes early. A second check near payment catches changes during slow form filling.

Does NDC remove the need for fare caching?

No, it changes what is safe to cache. NDC offers are created by the airline per request and can be personalised. Caching them for other users can show the wrong offer. Generic, high-volume searches can still be cached for a short time, with a live price check at booking.