当前位置:网站首页>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
边栏推荐
- YOLOV5学习笔记(二)——环境安装+运行+训练
- 8、统一处理异常(控制器通知@ControllerAdvice全局配置类、@ExceptionHandler统一处理异常)
- Atomic operation CAS
- 15、网站统计数据
- Uninstallation of mysql5.7.37 under CentOS7 [perfect solution]
- Local area network computer hardware information collection tool
- Installation of mysql5.7.37 under CentOS7 [perfect solution]
- Is interprofessional examination difficult?Low success rate of "going ashore"?Please accept this practical guide!
- 注解用法含义
- Detailed explanation of TCP (3)
猜你喜欢
随机推荐
WebSocket Session is null
els 方块向右移
16、热帖排行
CorelDRAW2022 streamlined Asia Pacific new features in detail
els 方块向右移动边界判断、向下加速
顺序表的实现
JetPack组件Databinding
VS QT——ui不显示新添加成员(控件)||代码无提示
Moxa NPort 设备缺陷可能使关键基础设施遭受破坏性攻击
一份高质量的测试用例如何养成?
Redis实现分布式锁
递归查询单表-单表树结构-(自用)
YOLOV5学习笔记(二)——环境安装+运行+训练
How to build a private yum source
Detailed explanation of TCP (2)
什么是系统?
What is a distributed lock?Three ways of implementing distributed lock
【HCIP】ISIS
测试中的误报和漏报同样的值得反复修正
SQALE 是什么