当前位置:网站首页>Distributed locks and three implementation methods
Distributed locks and three implementation methods
2022-07-31 03:11:00 【1.01】
I. What is a distributed lock
Distributed locks are a way to control synchronous access to shared resources between distributed systems. In order to prevent multiple processes in a distributed system from interfering with each other, it is necessary to coordinate these processes on different machines.
If one or a group of resources are shared between different systems or different hosts of the same system, when accessing these resources, mutual exclusion is often required to prevent mutual interference and ensure consistency. At this time, it is necessary toUse distributed locks.
Distributed locks should have the following conditions:
- In a distributed system environment, a method can only be executed by one thread of one machine at a time;
- Highly available acquire lock and release lock;
- High-performance lock acquisition and release;
- It is reentrant;
- Have a lock failure mechanism to prevent deadlock;
- It has the feature of non-blocking lock, that is, if the lock is not acquired, it will directly return the failure to acquire the lock.
Second, the way to realize distributed lock
| Implementation | Link |
|---|---|
| Distributed lock based on database | Click to view |
| Distributed lock based on cache (Redis) | Click to view |
| The principle of distributed lock based on Zookeeper | Click to view |
In terms of ease of understanding (from low to high)
Database > Cache > Zookeeper
From an implementation complexity perspective (low to high)
Zookeeper >= cache > database
From a performance perspective (high to low)
Cache> Zookeeper >= Database
From a reliability perspective (high to low)
Zookeeper > Cache > Database
边栏推荐
- 【C语言】求两个整数m和n的最大公因数和最小公倍数之和一般方法,经典解法
- 【C语言】三子棋(经典解法+一览图)
- JetPack component Databinding
- 【Cocos Creator 3.5】缓动系统停止所有动画
- 注解用法含义
- Moxa NPort device flaw could expose critical infrastructure to devastating attack
- 解析小结—自用
- SQL injection Less46 (injection after order by + rand() Boolean blind injection)
- 观察者模式
- 4、敏感词过滤(前缀树)
猜你喜欢
随机推荐
【异常】The field file exceeds its maximum permitted size of 1048576 bytes.
选好冒烟测试用例,为进入QA的制品包把好第一道关
【C语言】求两个整数m和n的最大公因数和最小公倍数之和一般方法,经典解法
SQL injection Less47 (error injection) and Less49 (time blind injection)
TCP和UDP详解
What is a distributed lock?Three ways of implementing distributed lock
分布式与集群是什么 ? 区别是什么?
3.5 】 【 Cocos Creator slow operating system to stop all animations
Day32 LeetCode
execsnoop tool
【HCIP】ISIS
Observer pattern
Office automation case: how to automatically generate period data?
7. List of private messages
SIP协议标准和实现机制
学习DAVID数据库(1)
4、敏感词过滤(前缀树)
Map.Entry理解和应用
TCP详解(三)
Moxa NPort device flaw could expose critical infrastructure to devastating attack








![[C language] Preprocessing operation](/img/69/0aef065ae4061edaf0d96b89846bf2.png)
