The double booking risk
A ticket booking system sells limited seats, a concert row or a flight. The danger is two users buying the same seat at the same moment. The whole design centers on guaranteeing each seat sells once.
Holds and reservations
- When a user picks a seat, the system places a temporary hold so others cannot grab it while the user pays.
- The hold has a time to live. If payment does not complete, the hold expires and the seat returns to the pool.
- This avoids locking a seat forever for an abandoned checkout.
Enforcing single sale
- The final purchase uses an atomic operation, a conditional update that only succeeds if the seat is still available.
- This may use a database transaction with row locking or a compare and set, so concurrent buyers cannot both win.
- Optimistic concurrency lets buyers proceed and rejects the loser at commit, fitting low contention well.
Handling popular events
- A flash sale creates extreme contention on a few seats. A queue or waiting room admits buyers in a controlled rate.
- Inventory counts are kept consistent so the system never oversells.
Key idea
A ticket booking system prevents double booking with temporary holds that expire and an atomic conditional purchase, using transactions or optimistic concurrency, plus queues to tame flash sale contention.