Part 2 of 8 · 2 min read
Scope and numbers
Few bookings, no mistakes.
Think of a theatre box office with 100 seats. Many people queue. The clerk must give each seat to one person only. Speed matters less than never selling a seat twice.
The same design fits other booking questions, such as Airbnb, flights and cinema tickets.
Questions and the answers assumed here (from the book's sample talk).
- Scale? A hotel chain with 5,000 hotels and 1 million rooms.
- Payment? In full when booking.
- Channels? The hotel website or app.
- Cancellation? Yes.
- Overbooking? Yes, 10 per cent. This means selling more rooms than exist, expecting some cancellations.
- Prices? They change from day to day, rising when the hotel is expected to fill.
Features. Show a hotel page and a room page. Reserve a room. An admin panel to add, remove or update hotels and rooms. Support overbooking. Searching for rooms is out of scope.
Requirements.
- R1. Handle high concurrency, since a popular hotel in peak season may have many people trying for the same room.
- R2. Moderate latency. A few seconds to confirm a reservation is acceptable.
- R3. No double booking.
- R4. Respect the overbooking limit.
Numbers (from the book). 1 million rooms, 70 per cent occupied, and an average stay of 3 days. Reservations per day: 1,000,000 × 0.7 / 3 = about 233,000, rounded to 240,000. Per second: 240,000 / 86,400 = about 3. This is a very small rate.
The customer flow is a funnel. A person views the room page, then the booking page, then books. Suppose 10 per cent move to the next step at each stage. Working back from 3 bookings per second, the booking page gets 30 queries per second and the detail page 300.
The key point: this is a low-traffic system. The difficulty is concurrency on a few hot rows, not volume.
Overbooking
Overbooking means accepting more reservations than there are rooms, on the expectation that some guests will cancel.
Example: a hotel with 100 rooms accepts up to 110 reservations for one night.
Check yourself: 1. Why is the booking rate so small? 2. What is the funnel, and why does it matter for page load? 3. Why is correctness more important than speed here?