Design an Event Booking System
MicrosoftSoftware Engineer · OnsiteLast updated
This question tests the ability to design a high-concurrency booking system, focusing on preventing double-bookings, managing seat availability, and ensuring atomic transactions.
Problem Statement
Design a scalable Event Booking System (e.g., for concerts or theater tickets) that allows users to browse events, select specific seats, and complete purchases.
Functional Requirements
- Users can view a list of events and their corresponding venue maps.
- Users can reserve specific seats for a limited time (e.g., 10 minutes) before completing the payment.
- Users can complete the purchase to finalize the booking.
- Once a seat is purchased, it must be marked as unavailable to other users.
Non-Functional Requirements
- High availability and scalability during peak traffic (e.g., ticket drops).
- Strong consistency for seat inventory: no two users should be able to book the same seat.
- Low latency for seat selection and checkout processes.
Deliverables
- High-level architecture diagram (describe the components).
- API design for seat selection and booking.
- Data model (schema overview for Events, Seats, and Bookings).
- Concurrency strategy: How do you handle the 'race condition' when two users click 'Book' on the same seat at the same time?
- Failure handling: What happens if a user abandons the checkout process?
Hints
Hint 1
Consider using a distributed locking mechanism or optimistic concurrency control on the database row to prevent overbooking.
Hint 2
Decouple the seat reservation from the actual payment processing to ensure the system remains responsive under heavy load.
Hint 3
Implement a TTL (time-to-live) mechanism, such as a background task or a cache expiry, to release held seats if payment is not finalized.
Follow-up questions
- How would you handle a sudden traffic spike where 100,000 users are trying to book 5,000 seats simultaneously?
- If the payment gateway API is down, how do you ensure the system remains consistent and provides a good user experience?
- How would you implement a 'Waiting Room' or queueing system to manage traffic during high-demand event releases?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.