当前位置:网站首页>Distributed agreement of Lease mechanism
Distributed agreement of Lease mechanism
2022-08-07 23:54:00 【Leisurely for summer】
1. What is the Lease mechanism
The Lease mechanism, translated as the lease mechanism, is a commonly used protocol in distributed systems and a common tool for maintaining data consistency in distributed systems.
The Lease mechanism has the following features:
- Lease is the issuer's commitment to data consistency over time;
- After the issuer issues the Lease, regardless of whether it is received or not, as long as the lease does not expire, the issuer will abide by the agreement;
- Lease holders can only use the promise within the validity period of the Lease. Once the Lease expires, the holder needs to give up the execution and re-apply for the Lease.
Take car rental as an example:

2. What problem does the Lease mechanism solve?
In a distributed system, how to confirm whether a node is working properly?If there are 5 copies 1-5.Among them, No. 1 is the master copy.

The most intuitive processing method in distribution is to maintain a heartbeat between each replica and the primary replica, hoping to judge whether the other party is still alive by the existence of the heartbeat.
The heartbeat method can't solve the problem of whether the nodes are normal under the distributed environment at all.Consider the following scenario:
1. At a certain time, the master node of Node1 suddenly has network jitter or network interruption (note: not downtime), resulting in the slave node unable to receive the heartbeat.

2. One of the remaining secondary nodes will be selected as the primary node.

There are four main solutions:
- Design a distributed protocol that can tolerate dual masters
- Raft Protocol - High sync low via Term version.
- Use the lease mechanism
- Involving Decentralization-Gossip Protocol
2. The principle of Lease
1. Introduce the central node to be responsible for issuing Lease

2. There is a network problem

If there is network jitter during 01:05, other nodes will fail to apply for Lease, because the central node will admit that there is a master node before 01:10, and other nodes are not allowed to apply for Lease
3. If the network recovers

4. If it reaches 01:10, the master node will renew the contract, and then issue a new lease

5. If the master node goes down, other nodes will fail to apply for Lease, and the master node will be acknowledged

6. The secondary node applied for Lease, and the application was successful. Because the Lease expired

3, fault tolerance of lease
The master node is down: The lease mechanism is inherently tolerant of network and lease receiver errors, and the time is the remaining expiration of the lease.Duration
Central node exception: The downtime of the issuer may cause all nodes to have no lease, and the system is in an unavailable state. The solutionJust use a small cluster instead of a single node as the issuer.
Time difference problem: There may also be an error in the clock between the central node and the master node, only the central node needs to consider the clock errorThat's it.
The length of lease time generally takes the experience value of 1-10 seconds.If it is too short, the network will be under great pressure. If it is too long, it will take too long to recover the commitment, which will affect the availability.
4. Application
- In GFS (Google File System), the Master decides which is the master copy through the lease mechanism, and the lease is carried in the heartbeat response message to each node.When the heartbeat is not received, wait for the lease to expire before issuing it to other nodes.
- In chubby, after paxos elects the master, the slave node will issue a lease to the master, and no other nodes will be selected as the master within the time limit.On the other hand, the master node sends a lease to each client node to judge whether the client is alive or dead.
边栏推荐
猜你喜欢

将一句话的单词进行倒置,标点不倒置。

云服务器中mongodb配置账号密码 图文讲解(全)

kaggle小白必看:小白常见的2个错误解决方案

PLC运动控制系列之梯形速度曲线

像素画家KIN作品欣赏

Eureka Basics

pinia详解

solidworls视图与模型及绘图操作快捷方式

2022-08-07:以下go语言代码输出什么?A:1 1;B:3 1;C:0 3;D:不能编译。 package main import ( “fmt“ “math“ ) func main

Projecting Your View Attentively: Monocular Road Scene Layout Estimation via Cross-view Transformati
随机推荐
基于消息中间件开发的优点
现代企业架构框架 — 业务架构
立秋是中稻收割的日子
Detailed explanation of SQL DNSlog injection
进制转换数学函数构造_GET之[CISCN 2019 初赛]Love Math
周末放松的方式
PHP auto-increment construct _GET
分析与处理时间序列数据的常用方法总结
Mongodb出现Error: couldn‘t add user: Could not find role: [email protected] 解决方法
本古里安大学|基于深度强化学习的稠密神经网络多目标剪枝
【云原生--Kubernetes】PV、PVC
同花顺炒股佣金最低是多少?开户安全吗?
Modern enterprise architecture framework - business architecture
【数据挖掘】滴滴公司数据挖掘工程师笔试题
银行科技岗面试
ThinkPHP 5.0 组合多条件whereOr查询,生成sql带括号
入职面经!!!
mysql select查询基本运算符练习题
PLC运动控制系列之梯形速度曲线
将一句话的单词进行倒置,标点不倒置。