Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
RAFT: Implementing Distributed Consensus with E...
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Tim McGilchrist
May 08, 2014
Programming
720
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
RAFT: Implementing Distributed Consensus with Erlang
Talk from Yow LambdaJam 2014 in Brisbane on RAFT Algorithm and implementing it in Erlang.
Tim McGilchrist
May 08, 2014
More Decks by Tim McGilchrist
See All by Tim McGilchrist
Dependently Typed State Machines
lambda_foo
0
210
Code reuse through polymorphic variants
lambda_foo
1
270
Either Error Success
lambda_foo
0
180
Idris States: Dependent types, not just for vectors?
lambda_foo
0
300
Other Decks in Programming
See All in Programming
sbt 2.0: takeoff
eed3si9n
0
170
Simple Storage Service(S3) is not simple
iwatsukayura
0
320
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
100
パスワード再設定メールのURLについて知っておこう
uyuki234
0
180
JIS keyboard support in Omarchy
lef237
0
160
APNsからLive Activityを開始する話
yumnumm
0
170
エージェントを使い続けるためのメタワーク / Meta-work for keeping using the agent
rkaga
6
1.8k
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
3
1.2k
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
180
Event is what happens
moro
2
1.3k
残高管理から台帳サービスへの進化
artoy
1
210
AI-Powered Domain-Driven Design
ziobrando
0
290
Featured
See All Featured
How GitHub (no longer) Works
holman
316
150k
How to build a perfect <img>
jonoalderson
1
6.2k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
640
The World Runs on Bad Software
bkeepers
PRO
72
12k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
[SF Ruby Conf 2025] Rails X
palkan
3
1.5k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
490
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
740
Skip the Path - Find Your Career Trail
mkilby
1
260
Chasing Engaging Ingredients in Design
codingconduct
0
370
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Transcript
Tim McGilchrist @lambda_foo lambdafoo.com Raft Implementing Distributed Consensus with Erlang
Outline ❖ Goals! ❖ The consensus problem! ❖ Outline RAFT
algorithm! ❖ Implementing in Erlang
Goals What I want you to get out of this
talk?! • Understand core ideas in RAFT! • Erlang / OTP as a tool for building systems! • Build your own implementation
Consensus In a distributed system, agreement among multiple processes on
a single data value, despite failures. ! ! Once they reach a decision on a value, that decision is final.
Potential Use Case ❖ Configuration Management! ❖ Distributed Transactions! ❖
Distributed Lock Manager! ❖ DNS and Resource Discovery
RAFT ❖ Design for understandability! ❖ Strong leader! ❖ Practical
to implement Goals Raft is a consensus algorithm that is designed to be easy to understand.
Messages ❖ RAFT only needs 2 messages.! ❖ RequestVote includes
term! ❖ AppendEntries includes term and log entries! ❖ Term acts as a logical clock
States 3 states a node can be in. Follower Candidate!
Leader
Leader Leader • Only a single leader within a cluster!
• Receives commands from client! • Commits commands to the log
Follower Follower • Appends commands to log! • Votes for
candidates! • Otherwise passive
Candidate Candidate! • Initiates Election! • Coordinates Votes
Leader Election Follower Candidate! Leader starts up timeout new election
gets majority of votes step down step down timeout restart election
Log Replication add 1 F2 F1 Leader AppendEntries add 1,
index 0 add 1, index 0
Log Replication add 1 add 1 add 1 F2 F1
Leader Ok OK
Log Replication add 1 add 1 add 1 F2 F1
Leader Executes command
Log Replication add 1 add 4 add 1 add 1
F2 F1 Leader AppendEntries add 4, index 1 add 4, index 1 Executes command Executes command
RAFT Summary ❖ 2 types of messages, RequestVote and AppendEntries!
❖ 3 states, Leader, Follower and Candidate! ❖ Save Entries to persistent log
Erlang ❖ Functional language! ❖ Fundamentally a concurrent language! ❖
Actor model as basic abstraction! ❖ No shared state between actors! ❖ OTP behaviours like supervisors and gen_fsm! ❖ Location independent message sending
Implementation Overview ❖ github.com/tmcgilchrist/sloop ! ❖ github.com/andrewjstone/ rafter! ❖ Each
node has 2 supervised behaviours! ❖ gen_fsm implementing the consensus protocol! ❖ gen_server wraps the log store! ❖ passes erlang terms as messages
sloop_fsm ❖ state machine implements leader election and log replication!
❖ each state is a function with multiple clauses! !
Supervisors sloop_sup sloop_fsm sloop_store sloop_state sender
Implementations ! ❖ raftconsensus.github.io! ❖ github.com/tmcgilchrist/sloop ! ❖ github.com/andrewjstone/rafter !
❖ github.com/goraft/raft
Summary ❖ Defined Distributed Consensus! ❖ Looked at core ideas
of RAFT! ❖ Erlang suits distributed systems! ❖ Map Erlang to RAFT
Thanks!