Using the Saga design pattern for transaction management in a microservice architecture
DOI: 10.31673/2412-9070.2024.023941
DOI:
https://doi.org/10.31673/2412-9070.2024.023941Abstract
The use of microservice architecture in software development, in which each service is a self-sufficient participant with its own area of responsibility, its own data store, set of technologies, and work environment, is challenging in the context of transactions in a distributed service mode. After all, from the point of view of reliability and integrity of the system, it is extremely important to ensure data consistency, which implies compliance with defined restrictions and rules, absence of contradictions and consistency of data between system components. The architecture built on microservice interaction provides capabilities for decomposition of complex tasks, operational implementation of new functionality, isolation of critical components and scaling of individual software components. As a rule, the microservice architecture implements the principle «Database per service» — an approach according to which each microservice uses its own database, instead of a single shared database, as is usually implemented in a monolithic architecture. To ensure data consistency, the SAGA design pattern can be used, which provides a set of instructions for the correct management of transactions in a distributed architecture. To avoid the use of distributed transactions, it is recommended to use the SAGA design pattern, which allows for global data consistency through sets of local and compensating transactions. The template is fault-tolerant and ensures system reliability and integrity.
Keywords: microservice; data store; distributed transaction; SAGA; consistency.