I’m working on the backend design for an on-demand application where customers can request a service and nearby providers can accept the request.
I’m currently trying to understand how to prevent race conditions when multiple customers request the same provider at nearly the same time.
For example, if two booking requests arrive within a few milliseconds:
How should the database handle the two transactions?
Is database locking enough, or should I use another approach?
Would Redis be useful for managing provider availability?
Should the booking status be updated through a REST API, WebSocket, or both?
How can I make sure the customer receives an accurate booking status in real time?
I’d appreciate advice from developers who have implemented similar concurrent booking or reservation systems.