What problem does the redis distributed lock solve?

你离开我真会死。 提交于 2019-12-11 16:47:15

问题


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:


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".



来源:https://stackoverflow.com/questions/54811994/what-problem-does-the-redis-distributed-lock-solve

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!