All system design challenges
#77 CQRS/Archival Storage

Booking History Service

Show every customer their past and upcoming bookings instantly, from years of data spread across many booking systems.

Asked at Expedia Amazon

What is being asked

Design the booking history service behind "My bookings" and customer support's lookup screen. Flights, hotels, cars and activities each have their own booking service and database; history must bring them together.

Requirements

Functional

  • List a user's bookings, newest first, filter by type and status.
  • Open one booking with its full details and change history.
  • Support agents search by booking reference, email or phone.

Non-functional

  • Fast reads (under 200 ms) even for users with hundreds of bookings.
  • Updates from booking services appear within seconds.
  • Keep records for years for legal and tax reasons, at reasonable cost.

Design

Flight bookingsHotel bookingsCar bookingsEvent busHistory projectorHistory read storeArchive storageHistory API
Boxes are services; rounded shapes are data stores and queues.
  1. Each booking service publishes events (created, changed, cancelled). They stay the source of truth.
  2. The projector builds a read model shaped for the screen: one summary row per booking, keyed by user_id and sorted by date. This is CQRS: writes and reads use different models.
  3. A separate search index serves support agents' lookups by reference, email or phone.
  4. Bookings older than, say, two years move to cheaper archive storage; opening one is slower but still possible.

Key decisions and trade-offs

  • Projection vs live joins. Calling four services on every page load is slow and fragile; a projection is fast but eventually consistent.
  • Partition by user. Almost every query is "this user's bookings", so a user's data lives together.
  • Out-of-order events. Use a version per booking and ignore older versions.
  • Hot vs cold. Most users only look at recent and upcoming trips; tiering storage cuts cost sharply.

Follow-up questions

  • A booking event was lost. How would you detect and repair the read model?
  • How do you merge history when a guest checkout later creates an account?
  • How do you handle a GDPR or data deletion request?
  • How would support search "all bookings for this phone number" efficiently?
Log in to tick off the challenges you have worked through. Log in