Design a Hotel Booking System
RipplingSoftware Engineer · OnsiteLast updated
This question tests your ability to design a distributed system that manages transactional integrity, high concurrency during bookings, and efficient searching for room availability.
Design a Hotel Booking System
Design a scalable hotel booking system similar to Expedia or Booking.com. The system must allow users to search for hotels based on location, dates, and occupancy, view availability, and book rooms.
Functional Requirements
- Search: Users can search for available hotels in a city for specific dates.
- Inventory: The system must accurately track room availability to prevent double-booking.
- Booking: Users can reserve a room, which involves a payment process and inventory deduction.
- Management: Hotel partners can update room pricing and inventory counts.
Non-Functional Requirements
- Consistency: Strong consistency is required for the booking process (no double-bookings allowed).
- Latency: Search queries should be fast, ideally under 200ms.
- Scalability: The system should handle high traffic during peak holiday seasons.
- Reliability: Payments must be processed reliably, even if the inventory service is under load.
Scale Assumptions
- 100,000 hotels globally.
- 50 million daily active users.
- High read-to-write ratio (100:1).
- Critical requirement: Support for "Flash Sale" events where thousands of users compete for the same inventory simultaneously.
Deliverables
- High-level architecture diagram (describe components).
- Database schema design (consider storage for availability).
- Strategy for handling high-concurrency booking requests.
- API interface design for search and booking.
Hints
Hint 1
Consider the trade-off between using a relational database for booking transactions and a search-optimized index like Elasticsearch for availability discovery.
Hint 2
For the inventory bottleneck, explore techniques like distributed locking or database-level atomic updates to ensure atomicity during reservation.
Hint 3
Think about how to handle read-heavy traffic by caching availability data, but acknowledge the challenge of cache invalidation during rapid bookings.
Follow-up questions
- How would you handle a situation where a user starts a booking process but fails to complete the payment within the allotted time?
- What modifications would you make to the database schema to support dynamic pricing that changes based on demand or proximity to the booking date?
- If the payment gateway experiences a temporary outage, how would you ensure that the reservation status is eventually reconciled without losing the user's booking request?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.