Distributed Consensus and the Raft Algorithm

Concepts of Programming Languages

Sebastian Macke

Rosenheim Technical University

About this Lecture: Some Thoughts

2

Distributed Programming

Terms are not always used consistently.

3

4

The two general problem

5

Discussion: How would you solve the problem?

Three armies, each led by a general, plan to attack a fortified city. The armies may arrive at different times to surround the city, and none of the generals can be certain whether all the armies will arrive at all. Consequently, they have not appointed a single leader.
For the attack to succeed, at least two armies must strike simultaneously. Therefore, the generals need to coordinate and agree on a precise time to launch the attack. They can only communicate by sending messengers.

6

What is Distributed Consensus?

The consensus problem requires agreement among a number of processes on a single data value.
Distributed consensus protocols can be used for distributed databases which should stay consistent:

7

The CAP Theorem

In a distributed system the following requirements can be met:

Pick Two: Only two requirements can be met -> CP, AP are typical (CA does not exists)

AP = DNS (Domain Name System)
CP = Cash Machine

8

Securing C and P

9

Two Phase Commit

Phases:

This is equivalent with two round trips in the two general problem.

10

What is Raft?

11

Who uses Raft?

12

The Raft Algorithm

13

Raft in Action

14

The Raft State Model

15

Implementing Raft with Go

The most prominent implementation is the Raft implementation of Etcd (Part of Kubernetes)

This implementation is highly optimized and abstracts from the Raft paper

Other implementations

16

Is it possible to build your own Raft implementation?

Requirements and Decisions

17

Interesting Parts

18

Exercise 8.2: Be Creative!

Three armies, each led by a general, plan to attack a fortified city. The armies may arrive at different times to surround the city, and none of the generals can be certain whether all the armies will arrive at all. Consequently, they have not appointed a single leader.
For the attack to succeed, at least two armies must strike simultaneously. Therefore, the generals need to coordinate and agree on a precise time to launch the attack.
To achieve this, they decide to use a simplified version of the Raft algorithm.

19

Summary

20

Thank you

Sebastian Macke

Rosenheim Technical University

Use the left and right arrow keys or click the left and right edges of the page to navigate between slides.
(Press 'H' or navigate to hide this message.)