Design a Ticket Booking System
Design the catalog, availability, pricing, reservation, and payment path for a high-demand movie and event ticketing platform.
Problem statement
Design a ticket booking system for movies and other events with assigned seats. Users find a show, pick seats on a map of the hall, hold the seats briefly, and pay. The same seat must never be sold twice.
Catalog. A theatre is in one city and has halls. Each hall has its own seats, and each seat keeps the same ID over time. A movie can credit many artists. A show is one movie or event in one hall at one start time. Store these catalog facts once and reuse them; keep each show's seat inventory separate from the catalog. Prices can differ by show and by seat category.
Search. Operators give each movie or event one category, such as movie, concert or comedy. Popularity is a score updated every few minutes from recent bookings and page views. Search results and popularity may be a few minutes behind sales.
Seat map. Each hall has published layout versions that record where every seat, aisle and empty gap sits. Each show uses one published layout version. The seat map must show the real sections, aisles and gaps instead of packing seats together by label. Live availability is shown on top of the layout by seat ID and is kept separate from the layout itself. Editing a hall's layout during an on-sale is out of scope.
One purchase per user per show. A signed-in user can complete at most one successful purchase for a show. One purchase can include several seats. The limit holds across different request keys, devices, admission leases and waitlist offers. It is per show, not per movie or per account lifetime. It is a rule about signed-in accounts, not a fraud-proof identity check. A successful booking uses up the user's purchase for that show, even if its tickets are later returned. If a checkout definitely failed, the user may try again. A timeout, an unknown payment result, or an expired seat hold or admission lease is not, on its own, a reason to allow another charge. Explain how your design keeps seat ownership and this rule correct when attempts run at the same time, replies get lost, and payments are reconciled.
Cancellation. A user can cancel a whole confirmed booking until 24 hours before the show starts. The full amount goes back to the original payment, exactly once. A repeated cancel request returns the first result; it never refunds twice or returns the seats twice. A purchase whose payment result is still pending can't be cancelled until that result is known. Cancelling does not let the user buy again for that show: their one purchase stays used up.
Waitlist for returned seats. Users can join the waitlist of a sold-out show. When seats come back, for example from a cancellation, and the show is sold out with eligible users waiting, each returned seat is offered to the waitlist. Otherwise it goes back on normal sale. Offers go to eligible waiting users in first-come, first-served order, one at a time. Each offer expires after a set time, and then the next eligible user in line gets it.
Virtual waiting room. For a popular on-sale, users wait in the show's virtual waiting room before they can pick and hold seats. When there is room, the user gets an admission lease: a pass into seat selection that expires after a set time. The lease only lets the user try to buy. It never gives them a seat or promises that tickets are left. This waiting room is separate from the sold-out waitlist above. When a lease expires, a seat hold already made stays valid and payment recovery continues.
What to build
- Users can search upcoming events by city, category and date, and sort the results by popularity.
- Users can see a show's seat map and which seats are free right now.
- Users can hold one or more free seats for a short time while they check out.
- Users can pay for held seats and get a confirmed booking with one or more seats. Retries and new request keys never create a second successful purchase or an overlapping charge.
- Users can cancel a whole confirmed booking before the cancellation cutoff and get their payment back once.
- Operators can set up cities, theatres, halls, seats, movies and artist credits, schedule shows that reuse them, and publish hall layout versions for the seat map.
- Before holding seats, users can get current availability and a versioned price quote. A confirmed booking keeps the quoted line items the user accepted.
- Users can join a sold-out show's waitlist and get offers for returned tickets.
- Users can join or leave a show's waiting room, get back their place or admission after reconnecting, and enter seat selection only while their admission lease is valid. The room admits eligible waiting users first come, first served, by the join order the server recorded, and limits how many are admitted at once.
At scale
- 10 million monthly active users and 50,000 active events.
- A popular on-sale can get 10,000 seat requests per second.
- An unpaid seat hold expires after 5 minutes.
- One hot show can have 100,000 users in its waiting room. At most 1,000 admission leases can be active for that show at once. Each lasts 2 minutes, and client polling can't extend it. These leases are separate from seat holds.
- Each user has at most one active waitlist entry per show, and each returned ticket backs at most one live waitlist offer.