Distributed Locks

Locking often isn’t a good idea, and trying to lock something in a distributed environment may be more dangerous. But sometimes we need to keep this risk and try to use a distributed lock for two main reasons:

  • Efficiency: a lock can save our software from performing unuseful work more times than it is really needed, like triggering a timer twice.
  • Correctness: a lock can prevent the concurrent processes of the same data, avoiding data corruption, data loss, inconsistency and so on.

You might also like: 
Distributed Locks Are Dead, Long Live Distributed Locks

We have two kinds of locks:

Source link