Design BookMyShow

Problem Statement:


Step-1: What is an online movie ticket booking system ?


Step-2: Requirements and Goals of the System


Step-3: Some Design Considerations


Step-4: Capacity Estimation

Traffic estimates:
Storage estimates:


Step-5: System APIs

Search Movies API
SearchMovies(keyword, city, lat_log, radius, start_datetime, end_datetime, postal_code, include_spell_check, results_per_page, sorting_order)
[ 
    {
        "MovieID": 1,
        "ShowID": 1,
        "Title": "Cars 2",
        "Description": "About cars",
        "Duration": 120,
        "Genre": "Animation",
        "Language": "English",
        "ReleaseDate": "8th Oct. 2014",
        "Country": "USA",
        "StartTime": "14:00",
        "EndTime": "16:00",
        "Seats": [
            {
                "Type": "Regular",
                "Price": 14.99,
                "Status": "Almost Full"
            }, 
            {
                "Type": "Premium",
                "Price": 24.99,
                "Status": "Available"
            }
        ] 
    },
    {
        "MovieID": 1,
        "ShowID": 2,
        "Title": "Cars 2",
        "Description": "About cars",
        "Duration": 120,
        "Genre": "Animation",
        "Language": "English",
        "ReleaseDate": "8th Oct. 2014",
        "Country": "USA",
        "StartTime": "16:30",
        "EndTime": "18:30",
        "Seats": [
            {
                "Type": "Premium",
                "Price": 24.99,
                "Status": "Almost Full"
            },
            {
                "Type": "Regular",
                "Price": 14.99,
                "Status": "Full"
            }
        ] 
    }
]
Reserve Seats API


Step-6: Database Design

Here are a few observations about the data we are going to store:

  1. Each City can have multiple Cinemas.
  2. Each Cinema will have multiple halls.
  3. Each Movie will have many Shows, and each Show will have multiple Bookings.
  4. A user can have multiple bookings.


Step-7: High Level Design

Step-8: Detailed Component Design

Ticket Booking Workflow:
  1. User searches for a movie.
  2. User selects a movie.
  3. User is shown the available shows of the movie.
  4. User selects a show.
  5. User selects the number of seats to be reserved.
  6. If the required no. of seats are available, the user is shown a map of the theater to select seats, if not, user is taken to ‘step-8’ below.
  7. Once the user selects the seat, the system will try to reserve those selected seats.
  8. If seats can’t be reserved, we have following options:
    • Show is full; the user is shown the error message.
    • The seats user wants to reserve are no longer available, but there are other seats available, so the user is taken back to the theater map to choose different seats.
    • There are no seats available to reserve, but all the seats are not booked yet as there are some seats that other users are holding in reservation pool and have not booked yet. The user will be taken to a waiting page where they can wait until required seats get freed from the reservation pool. This waiting could result in following options:
      • If the required number of seats become available, the user is taken to the theater map page where they can choose the seats.
      • While waiting if all seats get booked, or there are fewer seats in the reservation pool than the user intend to book, the user is shown the error message.
      • User cancels the waiting and is taken back to the movie search page.
      • At max, a user can wait one hour, after that user’s session gets expired and the user is taken back to the movie search page.
  9. If seats are reserved successfully, the user has five minutes to pay for the reservation.
  10. After payment, booking is marked complete. If the user is not able to pay within five minutes, all their reserved seats are freed to become available to other users.

How would the server keep track of all the active reservation that haven’t been booked yet? And how would the server keep track of all the waiting customers?


a. ActiveReservationService

ActiveReservationsService keeping track of all active reservations


b) WaitingUsersService
Reservation Expiration


Step-9: Concurrency



Step-10: Fault Tolerance

What happens when ActiveReservationsService or WaitingUsersService crashes ?


Step-11: Data Partitioning

Database partitioning:
ActiveReservationService and WaitingUserService partitioning:




← Previous: Design Uber