A modern computing system requires multiple components distributed on different machines to provide scalability, high availability, fault tolerance, and low latency. Therefore, consensus is essential when communicating between nodes to agree on some data value required during computation.
There are many examples of consensus around our tooling:
- Google Chubby uses Paxos, which is a consensus algorithm.
- Kubernetes uses etcd as the backing store for all cluster data. Etcd uses Raft, which is a consensus algorithm.
- Hadoop; Kafka uses ZooKeeper for service discovery; leader’s election, ... ZooKeeper uses a Paxos-variant algorithm.
- Blockchain cannot exist without consensus algorithms such as Proof-of-work; Proof-of-stake; ...
As the result, knowledge of consensus in the distributed system is crucial to understand the behavior of those systems. This presentation will:
Brief introduction about the consensus; challenges and achieved result.
Raft algorithm - the main consensus algorithm used in most of the recent systems.
Some references to get our hand wet on this topic:
https://medium.com/@isuruboyagane.16/what-is-consensus-in-distributed-system-6d51d0802b8c
https://www.youtube.com/watch?v=5m3eBWKjHtM&ab_channel=HasgeekTV
20. Protocols Applications
Paxos
- Multi Paxos
- Flexible Paxos
- Cheap Paxos
- PigPaxos
- …
• Google Chubby:
coarse grained lock service
• Google Spanner: Distributed Database
ZooKeeper Atomic Broadcast
Apache ZooKeeper:
• a centralised service for maintaining con
f
iguration
information, naming synchronization.
• Application: Ka
f
ka; Hadoop; …
Raft
• etcd: Distributed Key-value datastore (heart of
Kubernetes)
• CockroachDB (New-SQL Database)
• TIDB
Proof Of Work Blockchain such as Bitcoin; Ethereum
21. Protocols Implementations
Paxos
- Multi Paxos
- Flexible Paxos
- Cheap Paxos
- PigPaxos
- …
• Google Chubby:
coarse grained lock service
• Google Spanner: Distributed Database
ZooKeeper Atomic Broadcast
Apache ZooKeeper:
• a centralised service for maintaining con
f
iguration
information, naming synchronization.
• Application: Ka
f
ka; Hadoop; …
Raft
• etcd: Distributed Key-value datastore (heart of
Kubernetes)
• CockroachDB (New-SQL Database)
• TIDB
Proof Of Work Blockchain such as Bitcoin; Ethereum
26. Key Value
Raft
Key Value
Raft
Key Value
Raft
Leader
Follower 1
Follower 2
call
denied
leader: 127.0.0.2
Flow diagram when user sends a request to a follower node
27. Key Value
Raft
2. call
Key Value
Raft
Key Value
Raft
3. replicate
3. replicate
4. return
to FSM
1. Put K/V
5. return
Leader
Follower 1
Follower 2
waiting
quorum
Flow diagram when user sends a request to a leader node
78. 1 3
2
1 3 4 5 6
Leader
Follower
2
M
1 3
2
1 3 4 5 6
Leader
Follower
2
4 5 6
After updating state
Sending request
- Follower observes all logs are matched
- Follower applies all logs from index 3 -> 6 to the local log
79. 1 3
2
1 3 4 5 6
Leader
Follower
2
M
1 3
2
1 3 4 5 6
Leader
Follower
2
4 5 6
4 5 6
7
7
7
After updating state
Sending request
- Follower observes all logs are matched
- Follower applies log at index 7