System Design: Auto-expiring Ticket Reservations
Problem
Design a ticket-booking system where a reserved ticket automatically returns to the inventory if payment is not completed within 30 minutes.
Discuss and propose a design for:
-
Data model and state machine.
-
Reservation and payment flow.
-
Concurrency control to prevent overselling.
-
Timeout processing (auto-expiry) at scale.
-
Consistency guarantees and failure handling.
Assumptions
-
Tickets can be either seat-based (assigned seats) or general admission (GA) with a capacity count.
-
A reservation places a temporary hold for 30 minutes. If payment is completed within that window, the reservation becomes a purchase; otherwise, it expires and inventory is released.
-
High read/write throughput; horizontally scalable services.
-
Payment is processed by an external provider and can succeed/timeout/arrive late.