Design a Hotel Booking System
Understanding the Problem
🏨 What is a hotel booking system? A hotel booking system lets travelers find a place to stay for a set of nights, see what it costs and reserve it. Booking.com and Agoda list hotels that each have many identical rooms of a few types; Airbnb lists homes where each listing is usually a single bookable unit. Underneath both is the same problem: answer a huge number of "what's free in Lisbon from the 12th to the 15th?" questions quickly, and make the rare "book it" request strictly correct.
Interviewers ask this as "design Booking.com," "design Agoda" or "design Airbnb." They're the same system. The differences are in the inventory model (a hotel has 40 Deluxe Doubles; an Airbnb apartment has one of itself) and in the booking flow (Airbnb hosts can require approval). We'll design for hotels, show that an Airbnb listing is just a room type with a count of one, and cover host approval where it fits.
Functional Requirements
We'll agree with our interviewer on what guests can do. A real travel site also does reviews, loyalty points and partner onboarding, so it's worth being clear about what we're leaving out.
Core Requirements
- Users should be able to search for properties by location, check-in and check-out dates and number of guests, and see only places that are actually available.
- Users should be able to view a property's details, room types and the total price for their dates.
- Users should be able to book a room for a date range and pay for it.
- Users should be able to view and cancel their bookings, and hosts should be able to accept or decline requests.
Below the line (out of scope)
- Reviews and ratings.
- How hotels and hosts sign up and edit their listings (we'll assume listing data and prices arrive from somewhere).
- Dynamic pricing and revenue management.
- Messaging between guests and hosts.
Non-Functional Requirements
Ask your interviewer how big this is. For our design: 2 million properties with about 10 million room types (Airbnb-style listings count as one room type each), 200 million searches a day and 1 million bookings a day.
Core Requirements
- The system must never confirm two bookings for the same unit on the same night beyond what the property has. Booking needs strong consistency.
- Search should return in under 500 ms at p99, and can be slightly stale. A room shown as available may be gone a few seconds later, as long as booking catches it.
- Search should stay available even when the booking path is degraded. We favor availability for reads and consistency for writes.
- The system should handle peaks of around 10,000 searches per second (holiday weekends, sales).
Below the line (out of scope)
- Multi-region active-active writes for inventory. We'll keep each property's inventory in one home region.
- PCI scope beyond "we use a payment provider."
The back-of-the-envelope math is lopsided, and that's the point:
- Bookings: 1M a day is about 12 per second on average, maybe 100-150 at peak. Each booking touches one row per night, around 3 on average. That's a few hundred row updates per second, which any sharded relational database handles comfortably.
- Searches: 200M a day is about 2,300 per second, around 10,000 at peak. A search in a big city can match 2,000 properties. If we checked each candidate's availability in the database for 3 nights, that's 10,000 × 2,000 × 3 = 60 million inventory reads per second.
Those two numbers decide the design. The write path is small and must be correct, so we'll use a relational database with transactions. The read path is enormous and can be a bit stale, so availability has to be precomputed and served from the search index and caches, not looked up row by row.
Expect a look-to-book ratio in the hundreds or thousands: most people search many times and book once, if at all. Saying this out loud tells your interviewer you know which path to optimize for throughput and which to optimize for correctness.