java - Guaranteed memcached lock -
so, i'm trying implement distributed lock using memcached , add()'s store if not exist contract (java & spymemcached, applicable in language of course). of course, if instance goes away, lose lock thought add lock 3 times (e.g. mylock1, mylock2, mylock3) hash out 3 different instances.
but, i've realized if instances goes down hash changes (using spymemcached's redistribute failure mode) , it's when attempt made add() locks, hashes of 3 lock's not match of 2 remaining locks in memcached cluster.
so...any other ideas distributed locks using memcached? or impossible guaranteed lock i'm referring to?
edit: ok, in looking through spymemcached source code, redistribute mode, goes next active memcached instance in it's list, rather re-hashing anything, should work ok.
if want use memcached avoid introducing more stuff/complexity environment, consider small dedicated memcached config locking.
but if you're open solutions don't rely on memcached, i'd use zookeeper implement distributed lock in java. i'd use netflix curator utils make easier.
Comments
Post a Comment