Slot Booking Capacity Management

In booking system, I have slot with capacity. now lets consider there is only 1 capacity is available and more two users are trying book the slot, at the same time. how I can handle this scenario?

looking for any solutions from community.

How do you want to handle this scenario?

In general, there are a couple different ways to handle it, but you’d probably want to lock the table whenever the form is submitted to book a slot, to ensure that there are no race conditions with other submissions.

The specifics are really doing to depend upon your data model and your views.

You are right, Would like know more about locking the table row instead of table as there will be parallel booking might be happening on different rows.

or

can it possible like first in first out ?
if yes, what supporting packages will be needing for this.

See select_for_update

Yes, but is that really appropriate from a UI/UX perspective?

To implement this, the process would need to be independent of your Django processes, perhaps using something like a Celery task queue or a Channels worker, or a bit of code in your Django app to manage your own semaphores. (I really don’t recommend that last one except under some unusual circumstances, but it can be done that way.)

Will try by select_for_update first, seems easy solution. if not then with other options. @KenWhitesell thanks for this advice and congratulations on your work anniversary by the way. :star_struck: :star_struck: :star_struck:

1 Like