<s>
Raft	B-Operating_System
is	O
a	O
consensus	B-Operating_System
algorithm	I-Operating_System
designed	O
as	O
an	O
alternative	O
to	O
the	O
Paxos	B-Operating_System
family	O
of	O
algorithms	O
.	O
</s>
<s>
It	O
was	O
meant	O
to	O
be	O
more	O
understandable	O
than	O
Paxos	B-Operating_System
by	O
means	O
of	O
separation	O
of	O
logic	O
,	O
but	O
it	O
is	O
also	O
formally	O
proven	O
safe	O
and	O
offers	O
some	O
additional	O
features	O
.	O
</s>
<s>
Raft	B-Operating_System
offers	O
a	O
generic	O
way	O
to	O
distribute	O
a	O
state	B-Architecture
machine	I-Architecture
across	O
a	O
cluster	B-Architecture
of	O
computing	O
systems	O
,	O
ensuring	O
that	O
each	O
node	O
in	O
the	O
cluster	B-Architecture
agrees	O
upon	O
the	O
same	O
series	O
of	O
state	O
transitions	O
.	O
</s>
<s>
It	O
has	O
a	O
number	O
of	O
open-source	O
reference	O
implementations	O
,	O
with	O
full-specification	O
implementations	O
in	O
Go	B-Application
,	O
C++	B-Language
,	O
Java	B-Language
,	O
and	O
Scala	B-Application
.	O
</s>
<s>
Raft	B-Operating_System
is	O
not	O
a	O
Byzantine	B-Operating_System
fault	I-Operating_System
tolerant	O
(	O
BFT	O
)	O
algorithm	O
:	O
the	O
nodes	O
trust	O
the	O
elected	O
leader	O
.	O
</s>
<s>
Raft	B-Operating_System
achieves	O
consensus	B-Operating_System
via	O
an	O
elected	O
leader	O
.	O
</s>
<s>
A	O
server	O
in	O
a	O
raft	B-Operating_System
cluster	B-Architecture
is	O
either	O
a	O
leader	O
or	O
a	O
follower	O
,	O
and	O
can	O
be	O
a	O
candidate	O
in	O
the	O
precise	O
case	O
of	O
an	O
election	O
(	O
leader	O
unavailable	O
)	O
.	O
</s>
<s>
Raft	B-Operating_System
implements	O
consensus	B-Operating_System
by	O
a	O
leader	O
approach	O
.	O
</s>
<s>
The	O
cluster	B-Architecture
has	O
one	O
and	O
only	O
one	O
elected	O
leader	O
which	O
is	O
fully	O
responsible	O
for	O
managing	O
log	O
replication	O
on	O
the	O
other	O
servers	O
of	O
the	O
cluster	B-Architecture
.	O
</s>
<s>
The	O
consensus	B-Operating_System
problem	I-Operating_System
is	O
decomposed	O
in	O
Raft	B-Operating_System
into	O
two	O
relatively	O
independent	O
subproblems	O
listed	O
down	O
below	O
.	O
</s>
<s>
In	O
this	O
case	O
,	O
a	O
new	O
term	O
starts	O
in	O
the	O
cluster	B-Architecture
.	O
</s>
<s>
Raft	B-Operating_System
uses	O
a	O
randomized	O
election	O
timeout	O
to	O
ensure	O
that	O
split	O
vote	O
problems	O
are	O
resolved	O
quickly	O
.	O
</s>
<s>
Each	O
client	O
request	O
consists	O
of	O
a	O
command	O
to	O
be	O
executed	O
by	O
the	O
replicated	O
state	B-Architecture
machines	I-Architecture
in	O
the	O
cluster	B-Architecture
.	O
</s>
<s>
Once	O
the	O
leader	O
receives	O
confirmation	O
from	O
half	O
or	O
more	O
of	O
its	O
followers	O
that	O
the	O
entry	O
has	O
been	O
replicated	O
,	O
the	O
leader	O
applies	O
the	O
entry	O
to	O
its	O
local	O
state	B-Architecture
machine	I-Architecture
,	O
and	O
the	O
request	O
is	O
considered	O
committed	O
.	O
</s>
<s>
Once	O
a	O
follower	O
learns	O
that	O
a	O
log	O
entry	O
is	O
committed	O
,	O
it	O
applies	O
the	O
entry	O
to	O
its	O
local	O
state	B-Architecture
machine	I-Architecture
.	O
</s>
<s>
This	O
ensures	O
consistency	O
of	O
the	O
logs	O
between	O
all	O
the	O
servers	O
through	O
the	O
cluster	B-Architecture
,	O
ensuring	O
that	O
the	O
safety	O
rule	O
of	O
Log	O
Matching	O
is	O
respected	O
.	O
</s>
<s>
In	O
the	O
case	O
of	O
a	O
leader	O
crash	O
,	O
the	O
logs	O
can	O
be	O
left	O
inconsistent	O
,	O
with	O
some	O
logs	O
from	O
the	O
old	O
leader	O
not	O
being	O
fully	O
replicated	O
through	O
the	O
cluster	B-Architecture
.	O
</s>
<s>
This	O
mechanism	O
will	O
restore	O
log	O
consistency	O
in	O
a	O
cluster	B-Architecture
subject	O
to	O
failures	O
.	O
</s>
<s>
Raft	B-Operating_System
guarantees	O
each	O
of	O
these	O
safety	O
properties	O
:	O
</s>
<s>
State	B-Architecture
machine	I-Architecture
safety	O
:	O
if	O
a	O
server	O
has	O
applied	O
a	O
particular	O
log	O
entry	O
to	O
its	O
state	B-Architecture
machine	I-Architecture
,	O
then	O
no	O
other	O
server	O
may	O
apply	O
a	O
different	O
command	O
for	O
the	O
same	O
log	O
.	O
</s>
<s>
The	O
State	B-Architecture
Machine	I-Architecture
Safety	O
is	O
guaranteed	O
by	O
a	O
restriction	O
on	O
the	O
election	O
process	O
.	O
</s>
<s>
In	O
order	O
to	O
be	O
elected	O
,	O
a	O
candidate	O
has	O
to	O
contact	O
a	O
majority	O
of	O
the	O
cluster	B-Architecture
,	O
and	O
given	O
the	O
rules	O
for	O
logs	O
to	O
be	O
committed	O
,	O
it	O
means	O
that	O
every	O
committed	O
entry	O
is	O
going	O
to	O
be	O
present	O
on	O
at	O
least	O
one	O
of	O
the	O
servers	O
the	O
candidates	O
contact	O
.	O
</s>
<s>
Raft	B-Operating_System
determines	O
which	O
of	O
two	O
logs	O
(	O
carried	O
by	O
two	O
distinct	O
servers	O
)	O
is	O
more	O
up-to-date	O
by	O
comparing	O
the	O
index	O
term	O
of	O
the	O
last	O
entries	O
in	O
the	O
logs	O
.	O
</s>
<s>
In	O
Raft	B-Operating_System
,	O
the	O
request	O
from	O
a	O
candidate	O
to	O
a	O
voter	O
includes	O
information	O
about	O
the	O
candidate	O
's	O
log	O
.	O
</s>
<s>
This	O
implementation	O
ensures	O
the	O
State	B-Architecture
Machine	I-Architecture
Safety	O
rule	O
.	O
</s>
<s>
Timing	O
is	O
critical	O
in	O
Raft	B-Operating_System
to	O
elect	O
and	O
maintain	O
a	O
steady	O
leader	O
over	O
time	O
,	O
in	O
order	O
to	O
have	O
a	O
perfect	O
availability	O
of	O
the	O
cluster	B-Architecture
.	O
</s>
<s>
broadcastTime	O
is	O
the	O
average	O
time	O
it	O
takes	O
a	O
server	O
to	O
send	O
a	O
request	O
to	O
every	O
server	O
in	O
the	O
cluster	B-Architecture
and	O
receive	O
responses	O
.	O
</s>
<s>
It	O
can	O
take	O
several	O
weeks	O
or	O
months	O
between	O
single	O
server	O
failures	O
,	O
which	O
means	O
the	O
values	O
are	O
sufficient	O
for	O
a	O
stable	O
cluster	B-Architecture
.	O
</s>
<s>
CockroachDB	B-Operating_System
uses	O
Raft	B-Operating_System
in	O
the	O
Replication	O
Layer	O
.	O
</s>
<s>
Hazelcast	B-Application
uses	O
Raft	B-Operating_System
to	O
provide	O
its	O
CP	O
Subsystem	O
,	O
a	O
strongly	O
consistent	O
layer	O
for	O
distributed	O
data	O
structures	O
.	O
</s>
<s>
MongoDB	B-Application
uses	O
a	O
variant	O
of	O
Raft	B-Operating_System
in	O
the	O
replication	O
set	O
.	O
</s>
<s>
Neo4j	B-Language
uses	O
Raft	B-Operating_System
to	O
ensure	O
consistency	O
and	O
safety	O
.	O
</s>
<s>
RabbitMQ	B-Application
uses	O
Raft	B-Operating_System
to	O
implement	O
durable	O
,	O
replicated	O
FIFO	O
queues	O
.	O
</s>
<s>
TiDB	B-Application
uses	O
Raft	B-Operating_System
with	O
the	O
storage	O
engine	O
TiKV	O
.	O
</s>
