Distributed Consensus - Raft Leader Election | Systems Design Interview 0 to 1 with Ex-Google SWE

  Рет қаралды 8,345

Jordan has no life

Jordan has no life

Күн бұрын

Пікірлер
@ololga
@ololga 4 ай бұрын
In the past I didn't enjoy system design, but after trying it with Jordan my life changed and I started enjoying it. Thanks, Jordan for making all these videos!
@jporritt
@jporritt 5 ай бұрын
I appreciate this length of video. Really convenient for getting complex topics.
@sahilkalamkar5332
@sahilkalamkar5332 9 ай бұрын
At 7:52, so essentially if there is a node which has more up to date logs then the leader being considered for election, those extra writes will be ignored if someone else is chosen as leader?
@jordanhasnolife5163
@jordanhasnolife5163 9 ай бұрын
Yep, unless that write is in a majority of the nodes, in which case it isn't possible for there to be a new leader without the write
@sahilkalamkar5332
@sahilkalamkar5332 9 ай бұрын
@@jordanhasnolife5163 so if the leader being elected receives a no from one of the nodes, but receives a yes from other nodes, will the election move ahead?
@jordanhasnolife5163
@jordanhasnolife5163 8 ай бұрын
@@sahilkalamkar5332 As long as there are more "yes" votes than "no" votes, then the election should move along yeah
@radosawmul8963
@radosawmul8963 8 ай бұрын
@@jordanhasnolife5163 Hmm but what happens from the perspective of the user who actually inserted those rights? :O He has probably been presented with some "write successful" screen before and now his data is lost? Or is it like he haven't got confirmation that his write was successful, because quorum didn't agree on it yet. 👀
@jordanhasnolife5163
@jordanhasnolife5163 8 ай бұрын
@@radosawmul8963 Yep you got it - you only get confirmation of your write once it gets to a quorum of nodes. If it's in a quorum of nodes, then an election to a leader without the write could not have passed, since that quorum will all vote no.
@msebrahim-007
@msebrahim-007 6 ай бұрын
1 - (4:05) In general, how can a follower be behind the current term number? Does this imply the follow node went down and came back up at a time when there was a new term? 2 - (4:35) How is it possible that a follower is in a term number that is greater than or equal to the term number that is being proposed? Once again i'm thinking that this follower perhaps went down and is massively behind when it comes back online? As a follow up to this question, if this implies that there is already a leader for term 29, shouldn't the candidate stop its proposal altogether since there is already a leader for term 29?
@jordanhasnolife5163
@jordanhasnolife5163 6 ай бұрын
1) Since raft only requires a majority of nodes to proceed with an operation, a follower that is offline and then comes back online can be behind. So yeah as you implied it comes back online during the new term. 2) Any node, including an outdated follower can propose a new leader election. In this case, one of the up to date followers basically needs to veto and start its own leader election. Imagine we have 5 nodes, and it is term 29. The leader goes down, and a follower proposes and creates term 30 becoming the new leader. That new leader then goes down, and the old leader comes back up. The old leader notices there is no current leader, and proposes an election on term 29, only to be veto'd by all of the other followers who were on term 30. The candidate will stop its proposal once a majority of nodes either say "no" or "there is already a leader" and respond to it.
@bokistotel
@bokistotel 5 ай бұрын
@6:48 "If an older leader proposes a write with a lower epoch number than a current token we KNOW that it is an old leader". My question is why do we know for certain that is was an old Leader? Couldn't it be an old Follower that updated its epoch number? Or are we assuming that this is a single leader replication and the one who proposes a write by definition must be/was a leader ?
@jordanhasnolife5163
@jordanhasnolife5163 4 ай бұрын
You're correct on the 2nd thing you said
@yrfvnihfcvhjikfjn
@yrfvnihfcvhjikfjn Жыл бұрын
This dude is casually bragging about leaving his house. Smh not even a real shut in
@jordanhasnolife5163
@jordanhasnolife5163 Жыл бұрын
Lol imagine going outside
@reddy5095
@reddy5095 5 ай бұрын
Suppose we have 5 nodes A B C D E, A is the current leader and it went down, B proposes and gets a yes from C and does not get a reply from other nodes and so B considers itself leader, At the same time D also proposes and gets a yes from E and does not get a reply from other nodes, Since both B and D got majority votes both will think they are the leader right?
@jordanhasnolife5163
@jordanhasnolife5163 5 ай бұрын
Those aren't majorities. The "majority" size always applies to the original size of the cluster, which is 3 in this case
@sebuszqo3239
@sebuszqo3239 7 ай бұрын
hi, so what in case when we have 3 nodes and leader goes down? then election is 50:50? One node will say I am a candidate and if second one say "yes you are" everything is fine but what if the second node will say "no"?
@jordanhasnolife5163
@jordanhasnolife5163 7 ай бұрын
Yep! It's only fault tolerant to an extent, it can never be perfectly fault tolerant!
@zylophone777
@zylophone777 Ай бұрын
watching this today makes sense
@jordanhasnolife5163
@jordanhasnolife5163 Ай бұрын
I'm afraid America's consensus system is cooked though
@PrabhuMarappan7
@PrabhuMarappan7 7 ай бұрын
At 2:51, you say that each node complains after random unit of time. But is that because each node has a different time to wait till the next heartbeat or is there? Or both are different?
@jordanhasnolife5163
@jordanhasnolife5163 7 ай бұрын
Yeah exactly, each node gets configured with a slightly different time to start an election after thinking the leader is down
@dwivedys
@dwivedys 5 ай бұрын
Pretty, pretty tough! Consensus is as tough in tech as it is in real life I guess….
@rahullingala7311
@rahullingala7311 10 ай бұрын
How do the nodes know how much of it's log it should communicate with the other nodes? Won't the logs be too huge?
@jordanhasnolife5163
@jordanhasnolife5163 10 ай бұрын
They go backwards from the start one entry at a time to catch them up
@msebrahim-007
@msebrahim-007 6 ай бұрын
@@jordanhasnolife5163 Having trouble understanding "go backwards from the start". If we assume a leader has the following writes in its log 89 88 87 86 And a followers log is on write 86, does this mean the leader starts at write 87 and goes to 89? Then the leader will send 87-89 to the follower?
@jordanhasnolife5163
@jordanhasnolife5163 6 ай бұрын
@@msebrahim-007 It means they try to send 89, and the follower says wait I actually also need 88 and 87.
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 15 МЛН
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 17 МЛН
"Raft - The Understandable Distributed Protocol" by Ben Johnson (2013)
36:33
Strange Loop Conference
Рет қаралды 29 М.
Paxos Explained
9:30
Computational Thinking
Рет қаралды 890
Distributed Systems 6.1: Consensus
18:15
Martin Kleppmann
Рет қаралды 39 М.
Designing for Understandability: The Raft Consensus Algorithm
1:00:28
The Paxos Algorithm
24:50
Google TechTalks
Рет қаралды 122 М.