Consider a application like (Ticket Master or BookMyShow or anyother seat reservation application).
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.
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.