#lease #etcd #id #client #seconds #consensus #hot

failover

failover based on etcd

3 releases

0.1.2 Mar 8, 2023
0.1.1 Mar 8, 2023
0.1.0 Nov 24, 2022

#9 in #hot

Custom license

25KB
567 lines

failover

etcd-based consensus for [hot spare

Algorithm

Lease part

  1. Client asks etcd for an initial lease for N seconds and receives a lease id.
  2. The lease is renewed every N/2 seconds.
  3. If connection is lost then client uses the same lease id to renew the lease.

NOTE: It's ½64 chance that the lease ID is reused.

Election part

  1. Client starts a campaign with a random timeout. If election expires then there is another leader. Client asks etcd for the leader lease id and waits until it dies.
  2. Client polls etcd every lease lifetime seconds. If etcd returns -1 then leader is dead, goto 1.

Dependencies

~14–27MB
~485K SLoC