Unit content
Replicated logs and state machine replication
A service can be replicated by making several nodes apply the same commands in the same order.
The agreed sequence of commands forms a replicated log:
1: set x = 3
2: increment x
3: set y = 8
If every replica starts from the same state and the same command always produces the same next state, applying the same log in the same order keeps the replicas equivalent.
The difficult part is agreeing on the log when leaders fail, messages are retried or replicas contain different suffixes. A consensus protocol can choose which log entries become committed.
Once an entry is committed, replicas can apply it to their local state machine.
State machine replication therefore separates coordination from application logic: consensus orders commands; repeatable command execution derives the replicated state.