A Possible Solution set("s1", 42) set("s1", 42) set("s1", 25) set("s1", 25) set("s1", 1729) set("s1", 1729) KV-Store KV-Store Client Client Client set("s1", 25) set("s1", 42) set("s1", 1729)
A Possible Solution set("s1", 42) set("s1", 42) KV-Store KV-Store set("s1", 25) set("s1", 25) set("s1", 1729) set("s1", 1729) Client Client Client set("s1", 25) set("s1", 42) set("s1", 1729)
Raft Observation • Paxos originally explained as a single decree leaderless protocol.
Raft Observation • Paxos originally explained as a single decree leaderless protocol. • Leader added for efficiency, e.g., in MultiPaxos from last lecture.
Raft Observation • Paxos originally explained as a single decree leaderless protocol. • Leader added for efficiency, e.g., in MultiPaxos from last lecture. • Reduces conflicts. Reduces number of messages in the common case.
Raft Observation • Paxos originally explained as a single decree leaderless protocol. • Leader added for efficiency, e.g., in MultiPaxos from last lecture. • Reduces conflicts. Reduces number of messages in the common case. • But leader election is independent of actual protocol.
Raft Observation • Paxos originally explained as a single decree leaderless protocol. • Leader added for efficiency, e.g., in MultiPaxos from last lecture. • Reduces conflicts. Reduces number of messages in the common case. • But leader election is independent of actual protocol. • Raft combines these two processes in one protocol.
Raft Observation • Paxos originally explained as a single decree leaderless protocol. • Leader added for efficiency, e.g., in MultiPaxos from last lecture. • Reduces conflicts. Reduces number of messages in the common case. • But leader election is independent of actual protocol. • Raft combines these two processes in one protocol. • Leader election responsible for ensuring a good leader.
Raft Observation • Paxos originally explained as a single decree leaderless protocol. • Leader added for efficiency, e.g., in MultiPaxos from last lecture. • Reduces conflicts. Reduces number of messages in the common case. • But leader election is independent of actual protocol. • Raft combines these two processes in one protocol. • Leader election responsible for ensuring a good leader. • Consensus is just leader deciding on ordering and replicating decision.
Raft Log • Primitive: Maintain a consistent log across participants
Raft Log Index Term Command • Primitive: Maintain a consistent log across participants
Raft Log Index Entries with the same term from the same leader. Term Command • Primitive: Maintain a consistent log across participants
Raft Log Index Entries with the same term from the same leader. Term Command 0 0 set(x, 5) • Primitive: Maintain a consistent log across participants
Raft Log Index Entries with the same term from the same leader. Term Command 0 1 0 0 set(x, 5) set(x, 6) • Primitive: Maintain a consistent log across participants
Raft Log Index Entries with the same term from the same leader. Term Command 0 1 2 0 0 1 set(x, 5) set(x, 6) get(x) • Primitive: Maintain a consistent log across participants
Raft Log Index Entries with the same term from the same leader. Term Command 0 1 2 3 0 0 1 0 set(x, 5) set(x, 6) get(x) get(x) • Primitive: Maintain a consistent log across participants
Raft Log Index Entries with the same term from the same leader. Term Command 0 1 2 3 Terms should not go back 0 0 1 0 set(x, 5) set(x, 6) get(x) get(x) • Primitive: Maintain a consistent log across participants
Raft Log Index Term Command 0 1 2 0 0 1 set(x, 5) set(x, 6) get(x) 0 1 2 0 0 1 set(x, 5) set(x, 6) get(x) 0 1 2 0 0 1 set(x, 5) set(x, 6) set(z, 2)
Raft Log Index Term Command 0 1 2 0 0 1 set(x, 5) set(x, 6) get(x) 0 1 2 Two entries with the same index and term are identical. 0 0 1 set(x, 5) set(x, 6) get(x) 0 1 2 0 0 1 set(x, 5) set(x, 6) set(z, 2)
Raft Log Index Term Command 0 1 2 0 0 1 set(x, 5) set(x, 6) get(x) 0 1 2 0 0 1 set(x, 5) set(x, 6) get(x) 0 1 2 0 0 0 set(x, 5) set(x, 6) set(z, 8)
Raft Log Index Term Command 0 1 2 3 0 0 1 1 set(x, 5) set(x, 6) get(x) set(y, 6) 0 1 2 0 0 1 set(x, 5) set(x, 6) get(x) 0 1 2 0 0 0 set(x, 5) set(x, 6) set(z, 8)
Raft Log Index Term Command 0 1 2 3 0 0 1 1 set(x, 5) set(x, 6) get(x) set(y, 6) 0 1 2 3 0 0 1 1 set(x, 5) set(x, 6) get(x) set(y, 6) 0 1 2 0 0 0 set(x, 5) set(x, 6) set(z, 8)
Raft Log Index Term Command 0 1 2 3 0 0 1 1 set(x, 5) set(x, 6) get(x) set(y, 6) 0 1 2 3 0 0 1 1 set(x, 5) set(x, 6) get(x) set(y, 6) 0 1 2 3 0 0 0 1 set(x, 5) set(x, 6) set(z, 8) set(y, 6)
Raft Log Index Term Command 0 1 2 3 0 0 1 1 set(x, 5) set(x, 6) get(x) set(y, 6) 0 1 2 3 If two logs agree on an entry, they agree on the prefix 0 0 1 1 set(x, 5) set(x, 6) get(x) set(y, 6) 0 1 2 3 0 0 0 1 set(x, 5) set(x, 6) set(z, 8) set(y, 6)
Raft Log Index Term Command 0 1 2 3 0 0 1 1 set(x, 5) set(x, 6) get(x) set(y, 6) 0 1 2 3 If two logs agree on an entry, they agree on the prefix 0 0 1 1 set(x, 5) set(x, 6) get(x) set(y, 6) 0 1 2 0 0 0 set(x, 5) set(x, 6) set(z, 8)
Raft Log Index Term Command 0 1 2 3 0 0 1 1 set(x, 5) set(x, 6) get(x) set(y, 6) 0 1 2 3 If two logs agree on an entry, they agree on the prefix 0 0 1 1 set(x, 5) set(x, 6) get(x) set(y, 6) 0 1 0 0 set(x, 5) set(x, 6)
Raft Log Index Term Command 0 1 2 3 0 0 1 1 set(x, 5) set(x, 6) get(x) set(y, 6) 0 1 2 3 If two logs agree on an entry, they agree on the prefix 0 0 1 1 set(x, 5) set(x, 6) get(x) set(y, 6) 0 1 2 0 0 1 set(x, 5) set(x, 6) get(x)
Raft Log Index Term Command 0 1 2 3 0 0 1 1 set(x, 5) set(x, 6) get(x) set(y, 6) 0 1 2 3 If two logs agree on an entry, they agree on the prefix 0 0 1 1 set(x, 5) set(x, 6) get(x) set(y, 6) 0 1 2 3 0 0 1 1 set(x, 5) set(x, 6) get(x) set(y, 6)
Raft Timeline Term
Raft Timeline n o i t c e l E r e d a e L Term
L e a d Term e r R E e l i e g c n t i o n Raft Timeline
L e a d Term e r R E e l i e g c n t i o n L e a d e r E l e c t i o n Raft Timeline
L e a d Term e r R E e l i e g c n t i o n L e a d e r E l e c t i o n Raft Timeline
L e a d Term e r R E e l i e g c n t i o n L e a d e r E l e c t i o n Raft Timeline
Raft within a Term 0 0 set(x, 5) 0 0 set(x, 5) set(x, 6)
Raft within a Term 0 0 set(x, 5) AppendEntries(term=0, prevIdx =0, prevTerm=0, [(1,0, set(x,6)]) 0 1 0 0 set(x, 5) set(x, 6) AppendEntries(term=0, prevIdx =0, prevTerm=0, [(1,0, set(x,6)])
Raft within a Term 0 0 set(x, 5) AppendEntries(term=0, prevIdx =0, prevTerm=0, [(1,0, set(x,6)]) 0 1 How should the followers respond? 0 0 set(x, 5) set(x, 6) AppendEntries(term=0, prevIdx =0, prevTerm=0, [(1,0, set(x,6)])
Raft within a Term 0 1 0 0 set(x, 5) set(x, 6) (0, Success) 0 1 0 0 set(x, 5) set(x, 6) (0, Fail)
Raft within a Term 0 1 0 0 set(x, 5) set(x, 6) (0, Success) 0 1 What can the leader infer from this interaction? 0 0 set(x, 5) set(x, 6) (0, Fail)
Raft within a Term 0 1 0 0 set(x, 5) set(x, 6) 0 1 0 0 set(x, 5) set(x, 6) AppendEntries(term=-1, prevIdx=-1, prevTerm=-1, [(0,0, set(x, 5),(1,0, set(x,6)])
Raft within a Term 0 1 0 0 set(x, 5) set(x, 6) 0 1 0 0 set(x, 5) set(x, 6) 0 1 0 0 set(x, 5) set(x, 6)
Raft within a Term 0 1 ... 0 0 set(x, 5) set(x, 6) 0 1 22 23 24 ... 0 0 0 0 0 set(x, 5) set(x, 6) ... ... ... 0 1 ... 0 0 set(x, 5) set(x, 6)
Raft within a Term 0 1 ... 0 0 set(x, 5) set(x, 6) 0 1 22 23 24 ... 0 0 0 0 0 set(x, 5) set(x, 6) ... ... ... 0 1 ... 0 0 set(x, 5) set(x, 6)
Raft within a Term 0 1 ... 0 0 set(x, 5) set(x, 6) 0 1 22 23 24 ... 0 0 0 0 0 set(x, 5) set(x, 6) ... ... ... 0 1 22 ... 0 0 1 set(x, 5) set(x, 6) ...
Raft within a Term 0 1 22 ... 0 0 1 set(x, 5) set(x, 6) ... 0 1 22 23 24 ... 0 0 0 0 0 set(x, 5) set(x, 6) ... ... ... 0 1 22 ... 0 0 1 set(x, 5) set(x, 6) ...
Raft within a Term 0 1 22 ... 0 0 1 set(x, 5) set(x, 6) ... 0 1 ... 0 0 set(x, 5) set(x, 6) 0 1 22 ... 1 0 0 set(x, 5) set(x, 6) ...
Raft within a Term 0 1 22 ... 0 0 1 set(x, 5) set(x, 6) ... 0 1 22 ... 0 0 1 set(x, 5) set(x, 6) ... 0 1 22 ... 1 0 0 set(x, 5) set(x, 6) ...
Raft within a Term 0 1 22 ... 0 0 1 set(x, 5) set(x, 6) ... 0 1 22 ... 0 0 1 set(x, 5) set(x, 6) ... Log entries can be deleted. When is it safe to execute commands? 0 1 22 ... 1 0 0 set(x, 5) set(x, 6) ...
Need to ensure some log entries are never deleted.
Safety Through Leader Election • Want to make sure some set of entries always remain in the log.
Safety Through Leader Election • Want to make sure some set of entries always remain in the log. • Can only execute actions for such committed entries.
Safety Through Leader Election • Want to make sure some set of entries always remain in the log. • Can only execute actions for such committed entries. • Need to ensure this without communicating with former leader(s).
Safety Through Leader Election • Want to make sure some set of entries always remain in the log. • Can only execute actions for such committed entries. • Need to ensure this without communicating with former leader(s). • Leaders might die or disappear.
Recommend
More recommend