something about consistency form my perspective

1. The situation when to use the consensus algorithm

The problems that these distributed consensus algorithms want to solve.

For example, there is a membership system . There are 5 servers (S1, S2, S3, S4, S5) to store the member data. 

Now I want to recharge $100 for my account . 

I asked my father and my mother each to recharge $50 for my account.

S1 received my father's request and S2 received my mother's request.

My initial balance is zero.

Each server has their own data copy.

This problem may happen if without applying a consensus algorithm:

S1 and S2 both store 50 in my balance. I gave out $100 and I only get $50, what the fuck!


2. The raft consensus algorithm

Assume S1 is the leader of the current term.

S1 received the request to add 50 to my balance. This kind of request is reached only when a successful payment is reached.

S2 received the request to add 50 to my balance.

All servers can process clients requests, because a lot of client requests did not require a consensus algorithm. Such as I request to see how much my balance is . And for those requests that require a consensus algorithm, only certain operations need a consensus algorithm, not all operations.

S1 want to add 50 to my balance, and this operation need consistency, so S1 will append a entry such as add 50 to my balance because S1 is the leader of the current term.

S2 want to add 50 to my balance and S2 find S1 is the leader so S1 will redirect the request to S1.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值