raft and other stories
play

Raft and Other Stories Consensus Trilogy: Part III Rough Timeline - PowerPoint PPT Presentation

Raft and Other Stories Consensus Trilogy: Part III Rough Timeline for Today Talk about logistics and lab 0 Raft: You should all know this better than I do. Quiz and midterm course evaluation. Lab 0 and 2 Some Observations Nearly


  1. 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)

  2. 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)

  3. Raft Observation • Paxos originally explained as a single decree leaderless protocol.

  4. Raft Observation • Paxos originally explained as a single decree leaderless protocol. • Leader added for efficiency, e.g., in MultiPaxos from last lecture.

  5. 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.

  6. 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.

  7. 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.

  8. 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.

  9. 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.

  10. Raft Log • Primitive: Maintain a consistent log across participants

  11. Raft Log Index Term Command • Primitive: Maintain a consistent log across participants

  12. Raft Log Index Entries with the same term from the same leader. Term Command • Primitive: Maintain a consistent log across participants

  13. 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

  14. 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

  15. 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

  16. 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

  17. 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

  18. 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)

  19. 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)

  20. 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)

  21. 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)

  22. 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)

  23. 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)

  24. 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)

  25. 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)

  26. 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)

  27. 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)

  28. 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)

  29. Raft Timeline Term

  30. Raft Timeline n o i t c e l E r e d a e L Term

  31. L e a d Term e r R E e l i e g c n t i o n Raft Timeline

  32. 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

  33. 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

  34. 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

  35. Raft within a Term 0 0 set(x, 5) 0 0 set(x, 5) set(x, 6)

  36. 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)])

  37. 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)])

  38. 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)

  39. 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)

  40. 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)])

  41. 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)

  42. 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)

  43. 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)

  44. 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) ...

  45. 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) ...

  46. 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) ...

  47. 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) ...

  48. 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) ...

  49. Need to ensure some log entries are never deleted.

  50. Safety Through Leader Election • Want to make sure some set of entries always remain in the log.

  51. 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.

  52. 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).

  53. 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