Skip to content
Discussion options

You must be logged in to vote

There are many ways.

Usually things like this are handled in the database using things like transactions (and other functionalities, sometimes it depends on the database in use) . If a database can offer these guarantees it is usually said to be ACID compliant.

Each worker will attempt to make a booking in the database, but only one will succeed while the others will receive an error.

There are many other algorithms for distributed locking but they can be considerably more complicated you wont need them for your particular example.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
2 participants