<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Consensus on Hemant Sethi</title>
    <link>https://www.sethihemant.com/tags/consensus/</link>
    <description>Recent content in Consensus on Hemant Sethi</description>
    <generator>Hugo -- 0.146.0</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 10 Dec 2024 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://www.sethihemant.com/tags/consensus/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Raft</title>
      <link>https://www.sethihemant.com/notes/raft---2014/</link>
      <pubDate>Tue, 10 Dec 2024 00:00:00 +0000</pubDate>
      <guid>https://www.sethihemant.com/notes/raft---2014/</guid>
      <description>&lt;p&gt;&lt;strong&gt;Paper:&lt;/strong&gt; &lt;a href=&#34;https://raft.github.io/raft.pdf&#34;&gt;Raft&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;raft&#34;&gt;Raft&lt;/h2&gt;
&lt;p&gt;Paper -&amp;gt; &lt;a href=&#34;https://raft.github.io/raft.pdf&#34;&gt;https://raft.github.io/raft.pdf&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Usenix -&amp;gt; &lt;a href=&#34;https://web.stanford.edu/~ouster/cgi-bin/papers/raft-atc14.pdf&#34;&gt;https://web.stanford.edu/~ouster/cgi-bin/papers/raft-atc14.pdf&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Website -&amp;gt; &lt;a href=&#34;https://raft.github.io/&#34;&gt;https://raft.github.io/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Designing for Understandability Raft 2016 -&amp;gt; Video , Slides&lt;/p&gt;
&lt;p&gt;Raft User Study, 2013 -&amp;gt; Video, Slides&lt;/p&gt;
&lt;h3 id=&#34;motivation-replicated-state-machines&#34;&gt;Motivation: Replicated State Machines&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Service that is replicated on multiple machines:&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;raft-basics&#34;&gt;Raft Basics&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Leader based:&lt;/li&gt;
&lt;li&gt;Server states:&lt;/li&gt;
&lt;li&gt;Time divided into &lt;em&gt;terms&lt;/em&gt;:&lt;/li&gt;
&lt;li&gt;Request-response protocol between servers (remote procedure calls, or RPCs). 2 request types:&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;leader-election&#34;&gt;Leader Election&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;All servers start as followers&lt;/li&gt;
&lt;li&gt;No heartbeat (AppendEntries)? Start election:&lt;/li&gt;
&lt;li&gt;Election outcomes:&lt;/li&gt;
&lt;li&gt;Each server votes for at most one candidate in a given term&lt;/li&gt;
&lt;li&gt;Election Safety: at most one server can be elected leader in a given term&lt;/li&gt;
&lt;li&gt;Availability: randomized election timeouts reduce split votes&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;log-replication&#34;&gt;Log Replication&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Handled by leader&lt;/li&gt;
&lt;li&gt;When client request arrives:&lt;/li&gt;
&lt;li&gt;Log entries: index, term, command&lt;/li&gt;
&lt;li&gt;Logs can become inconsistent after leader crashes&lt;/li&gt;
&lt;li&gt;Raft maintains a high level of coherency between logs (Log Matching Property):&lt;/li&gt;
&lt;li&gt;AppendEntries consistency check preserves above properties.&lt;/li&gt;
&lt;li&gt;Leader forces other logs to match its own:&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;safety&#34;&gt;Safety&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Must ensure that the leader for new term always holds all of the log entries committed in previous terms (Leader Completeness Property).&lt;/li&gt;
&lt;li&gt;Step 1: restriction on elections: don&amp;rsquo;t vote for a candidate unless candidate&amp;rsquo;s log is at least as up-to-date as yours.&lt;/li&gt;
&lt;li&gt;Compare indexes and terms from last log entries.&lt;/li&gt;
&lt;li&gt;Step 2: be &lt;em&gt;very&lt;/em&gt; careful about when an entry is considered committed&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;persistent-storage&#34;&gt;Persistent Storage&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Each server stores the following in persistent storage (e.g. disk or flash):&lt;/li&gt;
&lt;li&gt;These must be recovered from persistent storage after a crash&lt;/li&gt;
&lt;li&gt;If a server loses its persistent storage, it cannot participate in the cluster anymore&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;implementing-raft&#34;&gt;Implementing Raft&lt;/h3&gt;
&lt;h3 id=&#34;client-interactions&#34;&gt;Client Interactions&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Clients interact only with the leader&lt;/li&gt;
&lt;li&gt;Initially, a client can send a request to any server&lt;/li&gt;
&lt;li&gt;If leader crashes while executing a client request, the client retries (with a new randomly-chosen server) until the request succeeds&lt;/li&gt;
&lt;li&gt;This can result in multiple executions of a command: not consistent!&lt;/li&gt;
&lt;li&gt;Goal: &lt;em&gt;linearizability&lt;/em&gt;: System behaves as if each operation is executed exactly once, atomically, sometime between sending of the request and receipt of the response.&lt;/li&gt;
&lt;li&gt;Solution:&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;other-issues&#34;&gt;Other Issues&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Cluster membership&lt;/li&gt;
&lt;li&gt;Log compaction&lt;/li&gt;
&lt;li&gt;See paper for details
Paxos Vs Raft by John Kubiatowicz.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Paper Link:&lt;/strong&gt; &lt;a href=&#34;https://raft.github.io/raft.pdf&#34;&gt;https://raft.github.io/raft.pdf&lt;/a&gt;&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p><strong>Paper:</strong> <a href="https://raft.github.io/raft.pdf">Raft</a></p>
<hr>
<h2 id="raft">Raft</h2>
<p>Paper -&gt; <a href="https://raft.github.io/raft.pdf">https://raft.github.io/raft.pdf</a></p>
<p>Usenix -&gt; <a href="https://web.stanford.edu/~ouster/cgi-bin/papers/raft-atc14.pdf">https://web.stanford.edu/~ouster/cgi-bin/papers/raft-atc14.pdf</a></p>
<p>Website -&gt; <a href="https://raft.github.io/">https://raft.github.io/</a></p>
<p>Designing for Understandability Raft 2016 -&gt; Video , Slides</p>
<p>Raft User Study, 2013 -&gt; Video, Slides</p>
<h3 id="motivation-replicated-state-machines">Motivation: Replicated State Machines</h3>
<ul>
<li>Service that is replicated on multiple machines:</li>
</ul>
<h3 id="raft-basics">Raft Basics</h3>
<ul>
<li>Leader based:</li>
<li>Server states:</li>
<li>Time divided into <em>terms</em>:</li>
<li>Request-response protocol between servers (remote procedure calls, or RPCs). 2 request types:</li>
</ul>
<h3 id="leader-election">Leader Election</h3>
<ul>
<li>All servers start as followers</li>
<li>No heartbeat (AppendEntries)? Start election:</li>
<li>Election outcomes:</li>
<li>Each server votes for at most one candidate in a given term</li>
<li>Election Safety: at most one server can be elected leader in a given term</li>
<li>Availability: randomized election timeouts reduce split votes</li>
</ul>
<h3 id="log-replication">Log Replication</h3>
<ul>
<li>Handled by leader</li>
<li>When client request arrives:</li>
<li>Log entries: index, term, command</li>
<li>Logs can become inconsistent after leader crashes</li>
<li>Raft maintains a high level of coherency between logs (Log Matching Property):</li>
<li>AppendEntries consistency check preserves above properties.</li>
<li>Leader forces other logs to match its own:</li>
</ul>
<h3 id="safety">Safety</h3>
<ul>
<li>Must ensure that the leader for new term always holds all of the log entries committed in previous terms (Leader Completeness Property).</li>
<li>Step 1: restriction on elections: don&rsquo;t vote for a candidate unless candidate&rsquo;s log is at least as up-to-date as yours.</li>
<li>Compare indexes and terms from last log entries.</li>
<li>Step 2: be <em>very</em> careful about when an entry is considered committed</li>
</ul>
<h3 id="persistent-storage">Persistent Storage</h3>
<ul>
<li>Each server stores the following in persistent storage (e.g. disk or flash):</li>
<li>These must be recovered from persistent storage after a crash</li>
<li>If a server loses its persistent storage, it cannot participate in the cluster anymore</li>
</ul>
<h3 id="implementing-raft">Implementing Raft</h3>
<h3 id="client-interactions">Client Interactions</h3>
<ul>
<li>Clients interact only with the leader</li>
<li>Initially, a client can send a request to any server</li>
<li>If leader crashes while executing a client request, the client retries (with a new randomly-chosen server) until the request succeeds</li>
<li>This can result in multiple executions of a command: not consistent!</li>
<li>Goal: <em>linearizability</em>: System behaves as if each operation is executed exactly once, atomically, sometime between sending of the request and receipt of the response.</li>
<li>Solution:</li>
</ul>
<h3 id="other-issues">Other Issues</h3>
<ul>
<li>Cluster membership</li>
<li>Log compaction</li>
<li>See paper for details
Paxos Vs Raft by John Kubiatowicz.</li>
</ul>
<hr>
<p><strong>Paper Link:</strong> <a href="https://raft.github.io/raft.pdf">https://raft.github.io/raft.pdf</a></p>
<hr>
<p><em>Last updated: March 15, 2026</em></p>
<p><em>Questions or discussion? <a href="mailto:sethi.hemant@gmail.com">Email me</a></em></p>
]]></content:encoded>
    </item>
  </channel>
</rss>
