Design a Hotel Booking Platform with Multi-Source Ingestion
Keep hotel data current from partner APIs, partner webhooks and crawled hotel websites, let travelers find hotels with free rooms for their dates in a city or map area, and book a room through a five-minute hold and card payment without selling a room twice.
Problem statement
Design a hotel booking platform. Its hotel data comes from outside sources, and travelers use it to find hotels with free rooms for their dates and to book a room.
For this exercise, assume the platform sells rooms that partner hotels offer on it.
A hotel's data has three parts: a profile (name, address and map location, photos, amenities, description), its room types (for example, a king room for two guests), and, for each room type and night, how many rooms the hotel offers on the platform and the price for that night.
That room count is the total the hotel offers on the platform; it does not go down when the platform sells a room. The platform hands each confirmed booking to an existing delivery service that sends it to the hotel.
For this exercise, assume the data arrives in three ways. Hotel chains and channel managers (companies that manage room sales for many hotels) expose APIs that the platform calls to read what changed since its last read.
Other partners call a webhook that the platform exposes each time something changes; they retry when the platform does not acknowledge in time, so an event can arrive twice or after a newer one.
Finally, the platform crawls hotel websites to fill in profile details that the partner data leaves out; crawling never supplies room counts or prices. Each hotel's IDs in its sources are mapped to one platform hotel ID when the hotel joins, so matching unknown hotels across sources is out of scope.
Travelers look for available hotels by location and dates. To book, a traveler opens a hotel's booking page, which shows a five-minute countdown, enters card details and pays.
For this exercise, assume a search covers a city or a map area, check-in and check-out dates and a number of guests, and lists hotels that have a room type for that many guests free on every night of the stay, with the total price for the stay, 20 hotels a page.
Also assume that opening the booking page for a room type sets one room of that type aside on every night of the stay until the countdown ends; that the card is charged through an external payment provider and the booking is confirmed only when the payment succeeds; that after a declined card the traveler may try another card until the countdown ends; and that if the countdown ends before the traveler submits payment, the rooms go back on sale.
For this exercise, also assume that cancellations, bookings of several rooms at once, reviews, loyalty points, setting prices, and the delivery of bookings to hotels are out of scope.
What to build
- The platform keeps every hotel's profile, room types, nightly room counts and nightly prices current from partner APIs it calls, partner webhooks and crawled hotel websites, and a slow or failing source does not hold up the others.
- A traveler can search a city or map area for check-in and check-out dates and a number of guests, and gets hotels that have a suitable room type free on every night, with the total price for the stay.
- A traveler who opens the booking page gets one room set aside for 5 minutes with a countdown, pays by card, and ends with a confirmed booking or a clear failure; rooms are never set aside or sold beyond the hotel's count, and a traveler is never charged without a booking.
At scale
- For this exercise, assume about 200,000 hotels, each with about 5 room types and about 50 rooms offered on the platform, sold up to 365 nights ahead.
- For this exercise, assume about 400 API connections cover 150,000 of the hotels and each accepts at most 5 requests a second; webhooks from the other 50,000 hotels reach 5,000 events a second in bursts, each event covering one room type and a range of nights; about 100,000 hotel websites are crawled about once a week, at most one page every 2 seconds per site. A room-count or price change from an API or a webhook should show in search within 2 minutes.
- For this exercise, assume up to 20,000 searches a second, answered within 500 ms at p99; search results may be up to 2 minutes out of date.
- For this exercise, assume up to 500 booking pages opened a second and 100 confirmed bookings a second at peak; opening the booking page places or refuses the hold within 1 second, and the payment provider usually answers within a few seconds but sometimes times out.