System Design | Seat reservation application like Ticket Master or BookMyShow

Consider a application like (Ticket Master or BookMyShow or anyother seat reservation application).

  • Based on the city selected, we show all the movies being screened in that city.
  • City will have multiple Cinema Hall.
  • Each Cinema Hall has multiple Screens.

Capacity Estimation : 6 billion page views per month and sells 15 million tickets booking per month.

Screen size may vary between 1000 to 1 lakh seats.

They provide user with 5 minutes of time to complete the payment after reserving the seat selected by the user. If the user fails to finish the payment within the time specified the seat will be released back to the free pool.

Before user is redirected to the payment page we change status of the SEATS selected by user as "RESERVED" in DB and make an entry in the cache for that particular SHOWID (key in the cache).

Lets say we have cached all the "BOOKED and RESERVED" seats for faster access in REDIS for each show instead of querying the database as below.

{SHOWID : [{SEAT_ID, TimeInterval}, {SEAT_ID, TimeInterval}......]}

If at any point of time if the user fails to do the payment in the 5 minutes of interval. we need to do below 2 things to release the seats back to the free pool.

  • Remove the seatID entry which was marked as "RESERVED" from the cache for that particular SHOWID which the user was trying to book.
  • Change the status of the seats back to "AVAILABLE" in the DB.

Now the problem is given that capacity estimates, how can we efficiently remove all the RESERVED seats back to the free pool if the user fails to pay within 5 minutes of time interval for each show across all the cities. So that other users can immediately see the status of those seats as AVAILABLE for booking

Since there will be huge number of RESERVED/BOOKED seats data for each SHOW across all the cities in the REDIS CACHE.

P.S : I have read about REDIS active way of EXPIRING the keys. But it randomly picks the key to check for expiration and if expired it will delete the entry. But these may lead to some of the seats status being still shown as RESERVED even though booking expiration time has exceeded until being picked by REDIS randomly.

Please suggest.

Comments (5)