SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 28
Design a hotel booking system
Guests search a property for a date range, compare room types and confirm a stay. Each hotel decides how many rooms of each type it sells per night, and selling one more than that means walking a guest to another hotel at your expense.
Requirements
- Search availability by property, room type and date range.
- Reserve one room of a type for every night in a stay, or fail the entire booking.
- Cancel a reservation and return its nights to inventory.
- Make booking and cancellation retries safe: a retried request never creates a second reservation or releases nights twice.
Constraints and assumptions
- 50,000 properties with about 6 room types each. Inventory is tracked per room type per night and sellable 365 days ahead.
- Peak load is about 1,000 searches per second and 20 booking attempts per second.
- Stays are 1 to 14 nights. The checkout day is not a night of the stay.
- Search results may be up to a minute stale; a confirmation must never oversell.
- A booking confirmation should complete in under one second at p99.
Out of scope for the first sketch
Payments and card holds · Assigning specific room numbers · Dynamic pricing and rate plans · Reviews and photos
Draw your design
Rough math and notes
SYSTEM DESIGN SKETCHBOOK / FOLLOW-UPS
Design a hotel booking system
Finish your first sketch before answering these. Cross out freely.
- Two guests try to book the last available room for overlapping nights at the same moment. What enforces the limit?
- The booking committed, but the guest app timed out and sends the request again. What does the retry receive?
- Search results are cached. Where does a guest learn that a room just sold out, and how stale is acceptable?
- Product wants to hold the room for 10 minutes while the guest fills in details. What changes, and what happens to holds that are abandoned?
- A popular property opens rooms for a festival weekend and hundreds of guests try in the same minute. Where does contention show up, and what do you do about it?
Compare afterwards: worked approaches and reading at sketchbook /questions/hotel-booking/review