Problem Description
Design an in-memory hotel booking system that manages reservations without relying on any external database. All system state must be maintained using in-memory data structures within a single process, though candidates may discuss extending to multiple nodes.
Requirements
The system must define appropriate APIs and underlying data structures to support the following core functionalities:
- Inventory Management:
- Add new hotels.
- Define various room types for hotels.
- Manage room inventory, either as a total count per room type or as individual room units.
- Availability Search:
- Search for available rooms within a specified date range (check-in to check-out).
- Booking Management:
- Create a new booking, reserving one or more rooms for a given date range.
- Cancel an existing booking.
- Concurrency Control:
- Implement mechanisms to prevent double-booking of rooms under concurrent reservation requests.
Constraints and Notes
- Data Persistence: All system state resides exclusively in memory. Assume a single process for the initial design, but discussions around extending to multiple nodes are welcome.
- Assumptions: Candidates are expected to clarify critical assumptions, such as handling time zones, the definition of "check-out exclusivity" (e.g., can a room be booked on the same day it's checked out?), and the maximum allowable date horizon for bookings.
- Design Discussion: The design should explicitly address complexity trade-offs for chosen data structures and algorithms, and thoroughly detail the approach to handling concurrent requests to ensure data integrity.
AI interview prep
Core dilemma
Managing mutable, complex state (hotel inventory, bookings) in a single-process, in-memory environment while ensuring correctness under high concurrency without the aid of a database's ACID properties.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Problem Description
Design an in-memory hotel booking system that manages reservations without relying on any external database. All system state must be maintained using in-memory data structures within a single process, though candidates may discuss extending to multiple nodes.
Requirements
The system must define appropriate APIs and underlying data structures to support the following core functionalities:
- Inventory Management:
- Add new hotels.
- Define various room types for hotels.
- Manage room inventory, either as a total count per room type or as individual room units.
- Availability Search:
- Search for available rooms within a specified date range (check-in to check-out).
- Booking Management:
- Create a new booking, reserving one or more rooms for a given date range.
- Cancel an existing booking.
- Concurrency Control:
- Implement mechanisms to prevent double-booking of rooms under concurrent reservation requests.
Constraints and Notes
- Data Persistence: All system state resides exclusively in memory. Assume a single process for the initial design, but discussions around extending to multiple nodes are welcome.
- Assumptions: Candidates are expected to clarify critical assumptions, such as handling time zones, the definition of "check-out exclusivity" (e.g., can a room be booked on the same day it's checked out?), and the maximum allowable date horizon for bookings.
- Design Discussion: The design should explicitly address complexity trade-offs for chosen data structures and algorithms, and thoroughly detail the approach to handling concurrent requests to ensure data integrity.