Design a Restaurant Reservation System
Understanding the Problem
🍽️ What is a restaurant reservation system? A restaurant reservation system lets diners find restaurants with a free table for their party size at a time they want, book it in a few taps, and get a confirmation and reminders before they go. OpenTable and Resy are the familiar examples. On the restaurant side, the same system runs the host stand: the floor plan, which table each party gets, walk-ins and the waitlist.
It looks like hotel booking with smaller units, but the inventory works differently. A hotel room is booked per night. A restaurant table is booked for a turn, an hour and a half or so that starts at any 15-minute slot, and which tables can seat a party depends on its size. A booking at 7:00 for four blocks a 4-top until about 8:30, so it also affects whether there's a table at 7:15, 7:30 and 8:00. Reminders are a requirement in their own right: they're how restaurants cut no-shows, and sending millions of them at the right time is its own small scheduling system.
Functional Requirements
Core Requirements
- Users should be able to search for restaurants by location, cuisine, date, time and party size, and see the times that are actually available.
- Users should be able to book a table for a party size and time.
- Users should be able to modify or cancel a reservation.
- Users should receive a confirmation right away and reminders before the reservation (for example, 24 hours and 2 hours before), with a way to confirm or cancel from the reminder.
Below the line (out of scope)
- Reviews, photos and menus.
- Paying for the meal, and point-of-sale integration.
- Loyalty points.
- Restaurant onboarding and billing.
Non-Functional Requirements
Ask your interviewer for scale. For our design: 100,000 restaurants, 500,000 reservations a day, 50 million searches a day, and bookings open up to 30 days ahead.
Core Requirements
- The system must never assign two parties to the same table at overlapping times.
- Search should return available times in under 500 ms, and can be a few seconds stale.
- Reminders should go out within a couple of minutes of their scheduled time, and never for a reservation that was cancelled or moved. Sending one twice is annoying; sending none defeats the point.
- The restaurant's host stand must keep working even if its internet connection drops during service.
Below the line (out of scope)
- Global multi-region writes. Each restaurant's data has a home region.
Some quick math:
- Bookings: 500,000 a day is about 6 per second on average. Dinner bookings cluster in the afternoon and evening, so call it 50-100 per second at peak. Per restaurant, even a busy one gets a few hundred bookings a day. Contention per restaurant is tiny, except during a popular restaurant's booking release.
- Searches: 50 million a day is about 600 per second, with peaks of a few thousand. Each search covers maybe 200 nearby candidates and a window of times. If computing one restaurant's availability means loading its tables and reservations and running the seating logic, that's hundreds of thousands of computations per second. We'll want availability precomputed.
- Reminders: two per reservation is 1 million messages a day, on the order of 12 per second on average and a few hundred per second at peak. Not a throughput problem, but a timing and correctness one.
The insight to share: booking volume is small and naturally partitioned by restaurant, so correctness is easy to get with ordinary transactions. The work is in availability (the seating logic is more complex than a counter, so precompute it) and in the reminder schedule (lots of small jobs at exact times that change when reservations change).