i’m sure this has been discussed elsewhere, but unfortunately i can’t seem to find it, so apologies in advance if this is a dup. What is the conflict resolution behavior if multiple ray cluster members put
the same object at the same time?
Each put creates a new copy of objects, so there’s no conflict!
1 Like
thanks for the quick response.
Let’s assume we’re implementing a counter that keeps its state in an object, and there are lots of parallel writes/increments being executed against the counter. How do you make sure their no write ‘overwrites’ an update that just happened a tiny fraction of a second before, from a different worker?
Ray objects are immutable, so it is not possible to have concurrent writes.
If you’d like to have immutable object, you can use an actor instead.
@ray.remote
class A:
def __init__(self):
self.counter = 0
def inc(self):
self.counter += 1
In this case, there will be only a single request processed at a time. The ordering from the same caller is guaranteed by Ray’s internal ordering protocol.