Skip to content

Commit edf2067

Browse files
committed
Prepare next lecture
1 parent 6d6ad41 commit edf2067

File tree

8 files changed

+281
-271
lines changed

8 files changed

+281
-271
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Each student will compare Go to one of these languages as Semester Work: Modula,
6464
## Lecture 8 - Distributed Programming
6565
- Introduction to Networking in Go
6666
- [Slides](https://s-macke.github.io/concepts-of-programming-languages/docs/08-Network-Programming.html)
67-
- [Slides](https://s-macke.github.io/concepts-of-programming-languages/docs/15-Distributed-Programming-Raft.html)
67+
- [Slides](https://s-macke.github.io/concepts-of-programming-languages/docs/08-Distributed-Programming-Raft.html)
6868
- [Exercise 8](docs/exercises/Exercise8.md)
6969

7070
## Lecture 9 - Systems Programming

docs/15-Distributed-Programming-Raft.slide renamed to docs/08-Distributed-Programming-Raft.slide

Lines changed: 30 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,31 @@ Terms are not always used consistently.
3030
*
3131
.background ./img/07-parallel-distributed.png 600 _
3232

33-
* Message Passing
34-
Message Passing is invoking behavior on a separate process (not necessarily on the same computer) by sending messages.
33+
: * Message Passing
34+
: Message Passing is invoking behavior on a separate process (not necessarily on the same computer) by sending messages.
3535

36-
Models for exchanging messages:
36+
: Models for exchanging messages:
3737

38-
- point to point (symmetric/asymmetric, synchronous/asynchronous)
39-
- remote procedure calls (RPC, RMI)
40-
- broadcasting and multicasting
38+
: - point to point (symmetric/asymmetric, synchronous/asynchronous)
39+
: - remote procedure calls (RPC, RMI)
40+
: - broadcasting and multicasting
4141

4242
: Sender schickt Nachricht an Empfänger
4343
: symmetrisch: beide kennen sich / asymmetrisch: nur ein eine Richtung
4444
: synchron: blockiert bis Nachricht gelesen
4545
: RPI: wie lokaler Prozeduraufruf
4646

47+
* The two general problem
48+
49+
.image ./img/08-two-generals-problem.png 400 _
50+
51+
- The two generals problem is a thought experiment in distributed computing and unsolvable when the communication might fail.
52+
- We need a pragmatic solution.
53+
4754
* What is Distributed Consensus?
48-
Distributed consensus is the problem how to achieve consistency in distributed systems. Distributed consensus protocols can be used for distributed databases which should stay consistent:
55+
56+
The consensus problem requires agreement among a number of processes on a single data value.
57+
Distributed consensus protocols can be used for distributed databases which should stay consistent:
4958

5059
- The system stays consistent even if some nodes goes down
5160
- The system stays consistent if a network partition occurs (but could get unavailable)
@@ -61,15 +70,15 @@ In a distributed system the following requirements can be met:
6170
Pick Two: Only two requirements can be met -> CP, AP are typical (CA does not exists)
6271
.link https://codahale.com/you-cant-sacrifice-partition-tolerance/
6372

64-
: AP = DNS, Cloud Computing
65-
: CP = Geldautomat
66-
: CA = RDBMS?
73+
AP = DNS (Domain Name System)
74+
CP = Cash Machine
6775

6876
* Securing C and P
6977
- All known algorithms use the concept of a quorum to detect network partition problems
7078
- Only the partition with the majority of nodes stay alive to ensure consistency
7179
- All known algorithms use the concept of a Master or Leader node to control replication
72-
- All known algorithms use a replicated log and implement a two phase commit
80+
- All known algorithms use a replicated log and implement a two phase commit.
81+
- A replicated log is a list of all changes which are applied to the system
7382

7483
: Consistency & Partition Tolerance
7584

@@ -91,7 +100,6 @@ Phases:
91100
.link https://github.com/lshmouse/reading-papers/blob/master/distributed-system/Zab:%20High-performance%20broadcast%20for%0Aprimary-backup%20systems.pdf The ZAB paper
92101
.link https://lamport.azurewebsites.net/pubs/lamport-paxos.pdf The Paxos Paper
93102

94-
95103
* Who uses Raft?
96104
- ectd - The Cloud Native key value store -> Part of Kubernetes!
97105
- Docker Swarm - Docker in cluster mode
@@ -133,42 +141,21 @@ Other implementations
133141
* Is it possible to build your own Raft implementation?
134142
Requirements and Decisions
135143

136-
- We want to stay as close a possible on the original specification
137-
- We want to make a Raft cluster local testable (as single process)
138-
- We want to use gRPC as middleware
139-
.link https://github.com/s-macke/concepts-of-programming-languages/tree/master/dp/kvstore/core/raft
140-
.link https://github.com/s-macke/concepts-of-programming-languages/tree/master/dp/raft
141-
142-
* Step I - Defining a KV Business API
143-
.code ../src/distributed/kvstore/kvstore-api.go
144-
145-
- This is the business API for setting and getting data in/out or Raft cluster
146-
147-
* Step II - The Raft Interface : AppendEntries
148-
.code ../src/distributed/kvstore/core/raft/noderpc.go /type NodeRPC/
149-
.code ../src/distributed/kvstore/core/raft/noderpc.go /AppendEntries/,23
150-
- The interface could be easily proxied with gRPC or run locally without proxy
151-
152-
* Step II - The Raft Interface : RequestVote
153-
.code ../src/distributed/kvstore/core/raft/noderpc.go /type NodeRPC/
154-
.code ../src/distributed/kvstore/core/raft/noderpc.go /RequestVote/,37
155-
156-
* Step III - Implement the Raft Interfaces in a Server/Node
157-
.code ../src/distributed/kvstore/core/raft/node.go /type Node/,28
158-
159-
* Step IV - Write Tests
160-
.code ../src/distributed/kvstore/core/raft/node_test.go /TestElection/,33
144+
- We want to stay close on the original specification, but focus especially on the leader election.
145+
- We limit our use case to only 3 nodes.
146+
- We want to use easy built-in network mechanisms in Go such as HTTP. JSON not strictly necessary
161147

162148
* Interesting Parts
163-
- Statemachine
164-
- Concurrency: Behavoir of remote calls, election and heartbeat timers
149+
- State Machine
150+
- Concurrency: Behavior of remote calls, election and heartbeat timers
165151
- Design: Timer implementation
166-
- Clean Architecture: Separation of Raft and server APIs
167-
- Clean Code: Testability
168152

169-
* Be Creative!
153+
* Exercise 8.2: Be Creative!
154+
- Write your own Raft Implementation!
155+
156+
.link https://github.com/s-macke/concepts-of-programming-languages/blob/master/docs/exercises/Exercise8.md
157+
170158
- Write your own Raft Implementation!
171-
.link https://www.youtube.com/watch?v=YbZ3zDzDnrw More information
172159

173160
* Summary
174161
- Go is an excellent choice to implement an distributed protocol like Raft

0 commit comments

Comments
 (0)