Design a Restaurant Table Reservation System
Design table booking for restaurants: diners see open times for their party size and book a table, staff manage tables and bookings, no table is ever booked twice, and popular restaurants stay responsive when a new day opens.
Problem statement
Design a restaurant table reservation system. For this exercise, assume diners pick a restaurant, see the open times for their party size and book a table; staff set up their restaurant's tables and see each day's bookings; and the same table must never be booked twice for overlapping times.
For this exercise, assume these rules: - Each table lists the party sizes it takes, for example a 4-seat table takes parties of 3 or 4. The system picks the table; diners don't choose one. - Online bookings are for parties of 1 to 8. A booking keeps its table for 90 minutes for parties of 1 to 4 and 120 minutes for parties of 5 to 8. - Bookings start every 15 minutes within the hours each restaurant sets, and are free (no deposit or payment). - Diners are already signed in, and a booking is confirmed in one step. Sending the same request again after a lost reply must not create a second booking. - A diner can cancel before the start time, and that time becomes bookable again. Staff mark each booking seated or no-show (the party never came). - Bookings open 30 days ahead. Popular restaurants open each new day at 9:00 a.m. local time, and many diners try to book at that moment.
For this exercise, also assume finding restaurants (search by place or food), waitlists, walk-ins, combining tables, reminders and reviews are out of scope.
What to build
- A diner chooses a date and party size for one or more restaurants and sees each one's start times that still have a free table that takes the party.
- A diner books one of those times; the system picks a table that takes the party and confirms at once, or says the time is gone. Sending the same request again never creates a second booking.
- A diner can cancel before its start time, and that table time becomes bookable again.
- Staff set up their tables and booking hours, see a day's bookings with their tables, and mark each booking seated or no-show.
At scale
- For this exercise, assume 50,000 restaurants with about 20 tables each, and about 500,000 bookings a day.
- For this exercise, assume about 3,000 requests for open times a second at the evening peak, each asking about up to 10 restaurants from a list of search results. The open times shown may be up to about 5 seconds behind the bookings, but a booking always checks the current state.
- For this exercise, assume about 200 popular restaurants open a new day at 9:00 a.m. local time. In the first minute after 9:00, the most popular one gets up to 10,000 booking attempts and all popular restaurants together up to 100,000, while each has fewer than 100 bookings to give out that day.
- For this exercise, assume every booking attempt should get a clear answer within about 2 seconds, even in that rush, and a confirmed booking must never be lost.