Handle concurrent requests to update the resources

171 Views Asked by At

In an interview i have been asked the below question.

In an inventory we have the quantity for an item is 2.

There are two concurrent requests to our distributed system

  • 1st request went to server1
  • 2nd request went to server2

Now we need to gracefully handle the use case by serving any one request successfully other with no stock available.

Conditions: We should not use table level locks to achieve this.

Kindly help me how can we achieve this.

0

There are 0 best solutions below