Ordering Requests: Part I
Learn how to ensure that replicas process requests in the same order.
Requirements for order
Replica coordination requires (alongside the agreement property) the order property, which states that every non-faulty state machine replica processes requests in the same relative order. One way to implement order is to assign unique identifiers to each request. This way, we can manage the order in which replicas process requests in the unique identifiers' total order.
With replicas processing requests according to the order of their unique identifiers, we define a request as stable at a state machine replica
Order implementation requires a method to assign unique identifiers to requests. This method also needs to be constrained by the assumptions that a client can make about the order in which state machines process requests:
[
] A state machine processes requests by one of its clients in the order the client issued the requests. For example, a client issues requests to a state machine in the following order: request , then request , and then request . In this case, will process first, then , and then . [
] If a client makes a request to state machine that causes another client to make a request to , then will process before .
These two assumptions do not necessarily mean that
Let's discuss three ways in which we can implement order implementation. Replicas will need a test to classify a request as stable. We will have a stability test section for all our order implementations where we explain how replicas can check whether a request is stable.
Note: You can review how unique identifiers can be generated in the Sequencer chapter.
Order implementation
Method 1: Logical clocks
A logical clock is a function that maps events to integers. A logical clock
Implementation
We can implement logical clocks in a distributed system by associating a counter
Process
increases after each event at . When
receives a message with a timestamp , resets based on the following equation:
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.