Monday, 12 June 2017

Concurrent updating of a data value in redis + socket.io

I'm implementing an API using NODEJS, where multiple users can make the simultaneous request for updating a value stored in Redis DB. Since all the operation are atomic, implementing this won't be any issue. so far, so good.

But the scenario I am facing is that: I have a threshold value(say T1). And if there are multiple clients(say 10) make a request to update the SAME value at the SAME time( say, T1+2 value store the database before 10 concurrent requests). So I need to successfully update the value for first 2 users AND for the rest of 8 socket clients will be notified with the LOW Balance(or failed operations).

NOTE: the request made by every individual will decrement the value by 1.

I have searched extensively for a couple of hours.

But could not find any complete solution. Is there any callback parameter being called where we can check for MINIMUM THRESHOLD situation or some kind of success/fail promises.

Any help would be highly appreciated.



via Kunal Sharma

No comments:

Post a Comment