KatInterview

Hotel Booking Platform: Fast Search, Oversell-Free Reservations

System DesignModel answer
MediumModel answerSystem Designsystem-designconsistencyidempotency

Last updated

Design a hotel search and reservation system that serves low-latency search from caches while guaranteeing strict, oversell-free transactional booking across multi-night stays.

Scenario

You are asked to design a worldwide hotel discovery and reservation platform (in the spirit of large online travel sites). Travelers search for lodging by destination and dates, view live price quotes, book rooms with payment, and later look up or cancel their reservations.

Functional Requirements

  • Search & discovery: Find hotels by location, check-in/check-out dates, and guest count. Filter by amenities, price range, and star rating.
  • Pricing & quotes: Show accurate quotes for the chosen date range, reflecting dynamic nightly rates and taxes.
  • Inventory & booking: Reserve a specific room type over a continuous range of nights. No night may ever exceed that room type's capacity (no overselling).
  • Lifecycle management: Support reservation lookup, cancellation, and automatic release of inventory.
  • Payment & idempotency: Integrate with external payment providers so users are never double-charged and never left with orphaned reservations.

Non-Functional Requirements

  • Consistency vs. availability: Search must be highly available and fast (< 200 ms). Booking must be strictly consistent (ACID) with zero overselling.
  • Idempotency: Every booking request must be strictly idempotent.
  • Privacy & compliance: Payment data (PCI-DSS) and customer PII must be segregated and protected.

Scale Assumptions

  • Hotels & rooms: 500,000 hotels, ~100 rooms each (~50M rooms total).
  • Search traffic: 50,000 read QPS at peak.
  • Booking traffic: 500 booking transactions per second at peak (~100:1 read-to-write).
  • Booking window: Reservations allowed up to 365 days ahead.

What Your Design Should Cover

  1. API design: Core endpoints for search, room holds, booking confirmation, and cancellation.
  2. Data model: Schema for hotels, room types, daily inventory records, and reservations.
  3. Inventory management & concurrency: How you serialize concurrent bookings across multi-night stays (e.g., optimistic locking, row-level locks, distributed locks, transactional decrement).
  4. Reservation lifecycle & state machine: Temporary holds, hold expiration (TTLs), payment settlement, and asynchronous webhooks.
  5. Search architecture: Caching, tolerating stale search data, and propagating inventory/price changes into the search index.

Hints

Hint 1

Separate the read path from the write path: search can be served from caches and an index, but bookings must hit an ACID store.

Hint 2

Model inventory as one row per (room type, night); then a stay is a bounded range of rows you can atomically check-and-increment.

Hint 3

Make every write idempotent by storing the Idempotency-Key in the same transaction as the state change.

Hint 4

Holds with TTLs plus a sweeper job let you free abandoned inventory without blocking users.