Introduction to Eventual consistency

Eventual consistency is a consistency model for the event-based distributed application to achieve high availability. If there are no changes for domain into a system, then it will return the last updated value for that domain. Eventual consistency is also known as optimistic replication and strongly used in distributed systems.

In the diagram of the CQRS pattern, we have used the cache for returning data for queries sent by the client, so, the cache will be updated if there are no changes for domain into a system. In fact, almost every cache is based on Eventual consistency.

Typically in event-sourced systems with Command Query Responsibility Segregation that need to display data to a client, we have three components that must cooperate:

As you can see, the Write Model accepts Commands and generates Event to its database and Cache to be updated. The read model accepts events and returns data objects to the frontend client.

We have discussed some patterns for the event-driven distributed system, such as event-driven architecture, Command Query Responsibility Segregation, Event Sourcing, and the Eventual consistency model. Now we will implement an event-driven asynchronous system using a messaging queue, such as Kafka and Spring Cloud Stream, in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset