I'm asked to create an online booking system with online payment and I'm wondering what to do in the case when 2 customers booked for the same room(s) at the same time.
For Example:
At the same time:
Customer1 and Customer2 booked for a standard room which only has 1 room available. (The Room availability will display that there is still 1 room available). And then they hit the 'confirm' button at the same time.
How to handle concurrency such that no two users are able to book same seat? Utilize transaction isolation levels. SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; for the seat and booking update. As Serializable level guarantees safety from Dirty, Nonrepeatable and Phantoms reads.
Unlike traditional hotel booking through travel agents, online hotel booking offers benefits to consumers such as accessing more photos and videos, a full description of the hotel property and location, better pricing, and no additional booking fees (O'Connor and Frew, 2004, Sparks and Browning, 2011).
The meaning or definition of a CRS or Central Reservation System is a type of reservation software that is used to update and maintain information of a hotel pertaining to inventory and rates so that hotels are able to manage guest reservations and the process around such reservations in real time.
A central reservation system (CRS) is a platform used by hotels to centrally manage and distribute room inventory, rates, and reservations. The CRS extracts rates from your PMS (property management system) and then writes back reservations into the PMS when booked across a variety of channels like GDS and IBE.
Use a locking construct (probably on the database level in this case) to ensure that only one confirmation will go through at once. You should always do this if it's possible to have a race condition like this. That way you will always know who was first, and you can tell the other user that they were too slow to confirm.
Another thing you might want to add is a payment time limit. In many systems, when you confirm something, you will have a certain amount of time to make a payment to get the reservation. If you don't pay within that time, the confirmation will expire and the room will once again be available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With