LLD Case Study: Movie Ticket Booking (BookMyShow)
Design a seat booking system with cities, theatres, shows and seats, and handle temporary seat locks and concurrent bookings correctly.
Intermediate · about 5 hours · difficulty 4/5
Learn first: LLD Case Study: Parking Lot, Relational Databases and SQL for Design
Movie or event booking is a favourite LLD problem in India because its hard part, two people trying to book the same seat, is a real concurrency problem.
Requirements
- Browse movies by city; list theatres and shows (a movie on a screen at a time).
- View the seat map with seat types (regular, premium, recliner) and prices.
- Select seats, hold them for a few minutes while the user pays, then confirm or release.
- Cancel bookings and refund per policy.
Core model
City, Theatre, Screen, Seat (row, number, type), Movie, Show (movie, screen, start time, pricing), ShowSeat (seat status per show: AVAILABLE, LOCKED, BOOKED), Booking (user, show, seats, amount, status), Payment. Separating Seat from ShowSeat matters: the same physical seat has a different status for every show.
Seat locking
- User selects seats. The system locks them atomically for that show with an expiry (say 5 to 10 minutes).
- Payment succeeds: seats move to BOOKED, booking confirmed.
- Payment fails or times out: locks are released.
Implementation choices:
- Database: a conditional update (UPDATE show_seat SET status = 'LOCKED', locked_until = ... WHERE id IN (...) AND status = 'AVAILABLE') and check the row count; or SELECT ... FOR UPDATE inside a transaction.
- Optimistic locking with a version column.
- In-memory lock service or Redis with expiries, backed by a DB constraint as the source of truth.
All selected seats must lock together or none should.
Patterns
Strategy for pricing (weekend, premium seats, dynamic pricing), State for booking status, Observer to push seat map updates to other viewers, Factory for payment methods.
Pitfalls
- Checking availability and then booking in two separate steps (a race).
- Locks without expiry, leaving seats stuck when users abandon payment.
- Partial locks when one of four selected seats is taken.
You are ready to move on when you can explain and code an all-or-nothing seat lock with expiry that stays correct under 100 concurrent attempts on the same seats.
Key concepts
- Theatre, screen, show and seat model
- Seat vs ShowSeat status
- Temporary seat locks with expiry
- All-or-nothing locking
- Booking state machine
- Pricing strategy
- Live seat map updates
Mini project
Build a booking service with an in-memory or Postgres store: lock seats with expiry, confirm on payment, release on timeout. Write a test that fires 100 concurrent requests for the same 2 seats and asserts exactly one booking succeeds.
Check yourself
Why should seat status live on a per-show entity rather than on the physical seat, and how do you release locks when a user closes the app mid-payment?
Free resources
- Awesome Low Level Design (GitHub)
- PostgreSQL explicit locking (PostgreSQL)
- State pattern (Refactoring.Guru)