Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I'm currently working on a project that involves a booking system. However, I've encountered an issue related to oversold bookings. Specifically, when two users attempt to book the same tickets simultaneously, the system sometimes ends up selling more tickets than available (e.g., selling 6 tickets when there are only 5).

To address this issue, I initially implemented a temporary booking system where a ticket is reserved for 10 minutes. However, I've noticed that if different users attempt to book the same tickets with very close timing, the problem persists.

What I have tried:

After conducting extensive research, I've come across a potential solution: implementing a queue system for bookings. The idea is to add bookings to a queue and then process them one by one by calling the booking API.

I'm currently working with NestJS and a MongoDB database, and I'm seeking guidance on how to implement this flow. If anyone has experience with this or has alternative solutions to address oversold bookings in a booking system, I would greatly appreciate your insights
Posted
Updated 19-Dec-23 4:31am
v2
Comments
[no name] 19-Dec-23 13:03pm    
https://www.jimmybogard.com/document-level-pessimistic-concurrency-in-mongodb-now-with-intent-locks/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900