CSE Roadmap

Core tier · about 3 hours · 7 parts

Part 2 of 7 · 2 min read

Requirements and numbers

Ask first, then count.

Think of a popular concert's ticket sale like a single narrow doorway that tens of thousands of people all try to walk through within the same thirty seconds. The design question is entirely about what happens at that doorway.

The question: design the database layer behind a ticket-booking system for live events. A customer picks an event, picks a specific seat, and buys it; no seat should ever be sold to two different customers.

Questions to ask, with the answers assumed here.

  1. Must every seat be unique to one buyer? Yes, this is the central correctness requirement.
  2. How many seats and events? Assume 2,000 seats per venue, 50 events on sale at once (made up to show the idea).
  3. What is peak load? A popular show can see 100,000 customers attempt to buy within the first minute of sale (made up to show the idea).
  4. Is a brief queue acceptable before checkout starts? Yes, customers already expect to wait during a popular on-sale.
  5. Must payment and seat-hold happen together? A seat is held temporarily once selected, then released if payment is not completed within a short window.

Requirements.

  • R1. No seat is ever sold to two different customers.
  • R2. A selected seat is held for a short window, then released automatically if unpaid.
  • R3. The system stays responsive even when 100,000 customers hit the same 2,000 seats at once.
  • R4. A customer sees a clear, immediate answer: seat held, seat unavailable, or payment confirmed.

Numbers. 2,000 seats per event means, in the worst case, 100,000 customers are competing for only 2,000 rows during the opening rush, a contention ratio of 50 to 1. That ratio, not the total seat count, is the number that actually matters here.

Contention ratio

A contention ratio is the number of concurrent attempts competing for the same limited set of rows, used to judge how severe lock contention will be under peak load.

Example: 100,000 customers competing for 2,000 seats gives a contention ratio of 50 to 1, a strong signal that naive locking will struggle.