有些时候,有些判断是无法做到真实,但是能做到最优也不错了

有些时候,有些判断是无法做到真实,但是能做到最优也不错了

比如
redis cluster的配置参数cluster-slave-validity-factor就运用了这种思维:
A slave of a failing master will avoid to start a failover if its data
looks too old.

There is no simple way for a slave to actually have a exact measure of
its “data age”, so the following two checks are performed:

1) If there are multiple slaves able to failover, they exchange messages
in order to try to give an advantage to the slave with the best
replication offset (more data from the master processed).
Slaves will try to get their rank by offset, and apply to the start
of the failover a delay proportional to their rank.

2) Every single slave computes the time of the last interaction with
its master. This can be the last ping or command received (if the master
is still in the “connected” state), or the time that elapsed since the
disconnection with the master (if the replication link is currently down).
If the last interaction is too old, the slave will not try to failover
at all.

The point “2” can be tuned by user. Specifically a slave will not perform
the failover if, since the last interaction with the master, the time
elapsed is greater than:

(node-timeout * slave-validity-factor) + repl-ping-slave-period

So for example if node-timeout is 30 seconds, and the slave-validity-factor
is 10, and assuming a default repl-ping-slave-period of 10 seconds, the
slave will not try to failover if it was not able to talk with the master
for longer than 310 seconds.

A large slave-validity-factor may allow slaves with too old data to failover
a master, while a too small value may prevent the cluster from being able to
elect a slave at all.

For maximum availability, it is possible to set the slave-validity-factor
to a value of 0, which means, that slaves will always try to failover the
master regardless of the last time they interacted with the master.
(However they’ll always try to apply a delay proportional to their
offset rank).

Zero is the only value able to guarantee that when all the partitions heal
the cluster will always be able to continue.

延伸

NP问题(Non-Deterministic Polynomial Complete Problems)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值