Seminar 8: Consistency models in distributed systems
Goal: To understand the concept of consistency models and implement a quorum system for consistency in python
Background: The term "consistency" in distributed systems refers to the agreement between data replicas or the rules that control how those replicas can be modified. Depending on the techniques employed in their design and implementation, distributed systems may be either consistent or inconsistent. Specifically, it determines how data is accessed and updated across multiple nodes in a distributed system, and how these updates are made available to clients.
- Golden rule for consistency: A process typically expects a read operation on a data item to deliver a value that displays the outcomes of the most recent write action on that data.
Types of Consistency Models
- Strong Consistency: In a strongly consistent system, all nodes in the system agree on the order in which operations occurred. Reads will always return the most recent version of the data, and writes will be visible to all nodes immediately after they occur. This model provides the highest level of consistency.
- Eventual Consistency: Eventual consistency ensures that if a node (let's say node N) has its data updated, the updated value will eventually spread to all of its replicas, making the replicas consistent with the original node (N). Nodes will ultimately become consistent, which means that updates will take some time to reach other copies.
Illustrations
- Strong Consistency
- Notation:
- Wi(x)a - denotes that Pi writes value a to data item x.
- Ri(x)a - denotes that process Pi reads data item x returning the value a.
There is a violation of the strong consistency because of assumption of NIL value set before read operations
- Eventual Consistency
Example: During the last seminar we introduced the concept of quorum system for consistency. We will be implementing the quorum system using gRPC with multiple threads in python using this (Code) .
Considering the two operations (write and read) in a cluster, the Gifford scheme constraints must be obeyed to have a correct choice of operations.
- Recall:
- Nw + Nr > N
- Nw > N/2
Task 1: Build on the sample code to define a self.id that contains N, Nr and Nw (e.g N = 6, Nr = 2 and Nw =4)of your choice and check for quorum validity of your defined data using gRPC in python. Output should show either Invalidity or Validity for the Gifford scheme
Task 2 Also synchronize the time of different operations using any clock algorithm
Deliverables: For each task, please contain the source python file, and also the screenshot of results in terminals. Then put all the file in a single zip.
Relative Links: