I'm working on an on-demand application where customers can request a service and nearby providers can accept the request.
I'm trying to figure out the best way to handle provider availability on the backend. For example, a provider may become available, receive multiple requests, accept one, and then immediately become unavailable to other customers.
What would be a good approach for handling this reliably?
I'm particularly interested in:
Preventing two customers from booking the same provider
Updating provider availability in real time
Choosing between WebSockets and polling
Handling location-based provider searches
Managing concurrent booking requests
Designing the database transactions to avoid race conditions
Would Redis, WebSockets, or database locking be appropriate for this type of system? I'd appreciate advice from anyone who has implemented a similar workflow.