Prevent Double Booking of Dining Reservations Under Concurrent Requests
Last updated: November 29, 2026
Quick Overview
Implement a booking function for park dining reservations that stays correct when many guests request the same time slot at once and when clients retry: never exceed slot capacity, never book a guest twice in a slot, and treat retries as the same request.
Disney
November 29, 20260
0
0 solved
Implement a booking function for park dining reservations that stays correct when many guests request the same time slot at once and when clients retry: never exceed slot capacity, never book a guest twice in a slot, and treat retries as the same request.
A databases and transactions question in the style of Disney Parks technology onsites, based on dining reservations that open at a fixed time and get heavy concurrent demand. The interviewer checks that you push the invariant into the database with conditional updates and constraints, and that you understand isolation and idempotency.
What the Interviewer Expects
- Explain the lost-update race in read-check-write code
- Use a conditional UPDATE so the capacity check and increment are one atomic statement
- Use unique constraints for per-guest and idempotency rules
- Wrap multi-statement changes in one transaction so failures roll back
- Discuss isolation levels and row locking in Postgres
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would this behave under Postgres READ COMMITTED versus SERIALIZABLE?
- How would you add a waitlist that fills cancellations fairly?
- How would you hold a slot for five minutes while a guest enters card details?
- What happens if the slot table becomes a hot row at 6 AM?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Slots have capacity in seats. book(slot, guest, party_size, idempotency_key) returns ok, full or duplicate. Invariants: seats booked never exceed capacity; a guest has at most one reservation per sl...
High-Level Design
The naive version reads booked, checks capacity in application code, then writes. Two requests can both read 2 of 6 and both add 4, overbooking. Fix it in the database: `UPDATE slots SET booked = bo...