So I'm trying to do a NodeJS code to allow a certain number of people to join a gym session. Issue here is when, for example, I have a session with 1 empty spot and two persons try to join at the exact same time. The checks that I run to know if the sesion is full do not work as none of them has already filled the spot so the app ends up letting both of them join.
I have tried bull queue system but I'm not sure if I'm in a good path or if it's the best option so far.
Any suggestion will help!
Thanks
In order to tackle this issue of simultaneous operations, you'll implement a scheme using a mix of methods like tool lock mechanisms, atomic processes, and queue structures. A potent strategy is to use a distributed lock manager, for example, Redlock, to ensure mutual exclusion during the updating of session availability.