SMR in Practice Via a Log

Let’s look at an overview of how SMR concepts are used in the Raft and Paxos algorithms.

By now, we have learned what state machine replication is and how it is implemented to toleratett faults. This lesson foreshadows the upcoming chapters on Paxos State Machine and Raft State Machine replications, both practical and widely used consensus algorithms. We will see how Paxos and Raft take the SMR ideas and implement them.

Log data structure

Every state machine of the replica group maintains a data structure called a log. We can consider a log as a file that consists of slotA slot can be considered a placeholder for client command or SMR's own internal commands. Each slot can store one command. numbers, starting from the left and extending indefinitely on the right. Often, these slot numbers are sequentially numbered starting from 1. Each slot can record just one client command (or some special system specific symbols as we will see shortly). These slots can exist in various states such as empty, written, committed, or executed. Initially, each slot is empty. At some point in a consensus algorithm, a user command is written to an empty slot. Depending on different consensus algorithms, written slots may or may not change once they are written. When it is confirmed that a majority of the replica group has successfully written the command to the same slot number, then this slot's status changes to committed. Once committed, a slot's value cannot change.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.