Hotel Reservation System Design: How to Answer It in a System Design Interview
3 views
"Design a hotel booking system like Booking.com or Marriott's reservation service" is a favorite system design interview question because it mixes ordinary CRUD with a genuinely hard problem: never selling the same room twice.
Start with requirements
Clarify scope before drawing boxes. Functional: search hotels by city and dates, view room types and prices, reserve a room type for a date range, cancel, and pay. Non-functional: high read traffic on search, much lower write traffic on bookings, strong consistency for inventory, and tolerance for a few seconds of staleness on search results. A reasonable scale assumption is 5,000 hotels, one million rooms, and a few hundred bookings per second at peak.
Model inventory by room type and date
A key insight to say out loud: guests usually book a room type (for example "King, city view"), not a specific room number. So store inventory as rows of (hotel_id, room_type_id, date, total_inventory, total_reserved). A three-night stay touches three rows. Interviewers like hearing that this keeps the hot table small and predictable.
Prevent double booking
This is the heart of the question. Walk through options:
- Pessimistic locking with SELECT ... FOR UPDATE on the date rows. Simple and correct, but holds locks under contention.
- Optimistic locking with a version column. Works well because real contention per hotel and date is low.
- A database constraint such as CHECK (total_reserved <= total_inventory * 1.1), where the 10 percent reflects allowed overbooking. Elegant and hard to get wrong.
Mention that the reservation and the inventory update must happen in one transaction, and that the client should send an idempotency key so a double-clicked "Book" button does not create two reservations.
Reservation lifecycle
Use states: pending, paid, cancelled, refunded. A pending reservation holds inventory for a short window (say 10 minutes) while payment completes; a background job releases expired holds. Payment goes through a separate payment service, and a webhook or message updates the reservation state.
Scaling reads and writes
Search is read-heavy: cache hotel and room-type metadata, and precompute availability summaries per city and date in a search index that can lag slightly. For writes, shard the reservation and inventory tables by hotel_id, since nearly every booking touches only one hotel. That keeps transactions local to a single shard and avoids distributed transactions.
Things interviewers probe
- What happens if payment succeeds but the reservation update fails? (Retry with idempotency, plus reconciliation jobs.)
- How do you handle a flash promotion on one hotel? (Rate limiting, queueing, and the optimistic-lock retry budget.)
- How do you support overbooking safely? (Configurable ratio in the constraint.)
Practicing out loud
The hardest part is usually not the design but explaining trade-offs clearly while someone interrupts with follow-ups. Rehearse with a friend, record yourself, and time each section. Some candidates also use Linkjob AI (https://linkjob.ai), which provides real-time help during job interviews and technical interviews, to stay structured when the follow-up questions start coming fast.