Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Leader address/location in Raft

This may be a very simple question but I've not been able to find a good answer to this yet. Maybe someone can help me.

Once a leader is elected -

  1. The clients will send all requests ONLY to the leader. Is this correct?
  2. Given that the location (for all practical purposes the IP address) of the leader is dynamic, how will the client know this IP address in a cluster?
like image 417
Soumya Simanta Avatar asked Aug 10 '14 15:08

Soumya Simanta


People also ask

Can raft have multiple leaders?

Yes you are right. There can be multiple leaders at the same time, but not in the same term, so the guarantee still holds. A possible situation is in a 3-server (A, B, C) cluster, A becomes elected.

How is the leader selected in the raft ordering system?

The Raft algorithm divides time into smaller terms of arbitrary lengths. With each term, an election is initiated, and a leader is chosen by majority vote. In case of no majority, the term terminates without any leader. The term number increases monotonically and is exchanged in every communication.


Video Answer


1 Answers

The client attempts to submit requests to any host in the cluster. If the client guesses wrong the server either forwards the request to the leader or returns an error with the address of who it thinks is the leader.

The first method (forwarding to the leader) is a better experience for the client. Be sure to limit the number of forwarding hops and timeout on the client.

The second method (error with leader address) is much easier to implement. Since the leader is typically long-lived except during troubled times, it usually only takes one retry to get the request to the leader.

like image 101
Michael Deardeuff Avatar answered Oct 11 '22 18:10

Michael Deardeuff