Design a ticket booking system
Selling seats is a small inventory problem wrapped in a very large traffic problem, and the two need opposite designs. This works it in interview order, with a conditional seat hold that expires on its own, a payment step that cannot double-sell, and an admission queue paced by the seats that are actually left.
What you'll be able to do
- Separate the read-heavy catalogue from the strongly consistent seat inventory, and justify a different store and cache policy for each
- Implement a seat hold as one conditional update whose expiry needs no background job for correctness
- Order the payment steps (authorise, confirm, capture) so that a timeout or a late payment can never sell a seat twice
- Size an admission queue from inventory rather than from server capacity, and show what each choice does to the people waiting
Before this: contention-and-locking, scaling-reads
Log in to read the rest of this lesson
Selling seats is a small inventory problem wrapped in a very large traffic problem, and the two need opposite designs. This works it in interview order, with a conditional seat hold that expires on its own, a payment step that cannot double-sell, and an admission queue paced by the seats that are actually left. This walkthrough runs about 28 minutes, with runnable code you can edit and re-run as you read. A new account gets 7 days of Pro free, no card required.
Log in to continueThe first module of every track is free to read on the web: see what's open in System design.