What problem does the redis distributed lock solve

2019-08-24 07:13发布

So I just read about redlock. What I understood is that it needs 3 independent machines to work. By independent they mean that all the machines are masters and there is no replication amongst them, which means they are serving different types of data. So why would I need to lock a key present in three independent redis instances acting as masters ? What are the use cases where I would need to use redlock ?

1条回答
甜甜的少女心
2楼-- · 2019-08-24 07:54

So why would I need to lock a key present in three independent redis instances acting as masters?

It's not that you're locking a key within Redis. Rather, the key is the lock, and used to control access to some other resource. That other resource could be anything, and generally is something outside of Redis since Redis has its own mechanisms for allowing atomic access to its data structures.

What are the use cases where I would need to use redlock?

You would use a distributed lock when you want only one member at a time of a distributed system to do something.

To take a random example from the internet, here's Coinbase talking about their use of a distributed lock to "ensure that multiple processes do not concurrently generate and broadcast separate transactions to the network".

查看更多
登录 后发表回答