Handling distributed transactions.

When everything is normal, the API composition and CQRS patterns can provide appropriate solutions for distributed queries.

However, maintaining the integrity of distributed data is complex. If you store all data in a single relational database and specify the appropriate constraints in the schema, you can rely on the database engine to maintain data integrity.

The situation is very different when multiple microservices keeps the data in isolated data stores (relational or non-relational). Data integrity is critical, but it must be maintained by code. The saga pattern addresses this concern.

A common measure of data integrity is that all transactions that modify data have the ACID properties:

  • Atomic: All operations in the transaction succeed or all fail.
  • Consistent: The data state meets all constraints before and after the transaction
  • Isolated: Concurrent transactions behave as if they are serialized.
  • Durable: When a transaction completes successfully, the results are persisted.

#saga #transactions #patterns #microservices

The Saga Pattern in Microservices
1.45 GEEK