Using the Eventually Trait

Explore eventual consistency and how to test eventually-consistent code in ScalaTest.

In this lesson, we’ll learn how to make our tests robust in eventually-consistent systems.

Strong consistency vs. eventual consistency

In a distributed system, data is typically replicated across multiple nodes for availability, fault tolerance, and scalability. However, when data is replicated across multiple nodes, the nodes might not always agree on the current state of the data. This can lead to inconsistencies in the system. Consistency models provide a way to define the level of agreement that nodes in a distributed system should have about the current state of the data. There are various consistency models, but the two most commonly used are strong and eventual consistency.

Strong consistency guarantees that all nodes in the system see the same version of data at the same time, regardless of which node is accessed. In other words, if a write operation is performed on one node, all subsequent reads on any node will return the updated value. Strong consistency ensures that all operations on the data will be seen as atomic and executed in a sequential manner as if they were ...