SAGA IMPLEMENTATION USING THE OUTBOX PATTERN

Authors

DOI:

https://doi.org/10.32782/tnv-tech.2023.4.4

Keywords:

microservice architecture, distributed transactions, data consistency, Saga design pattern, Transitional Outbox, Event Sourcing

Abstract

Microservice architecture provides a number of advantages, which include flexibility, fault tolerance, and the ability to reuse functionality. But the distributed nature of such systems makes it difficult to manage interactions and data consistency between different services. Applications need to perform transactions spanning multiple services, each with its own database and isolated. To manage transactions in systems with a microservice architecture, the Saga design pattern is used, which represents a distributed transaction as a sequence of local transactions. Typically, a local transaction updates the service database and publishes a message to initiate the next local transaction in the saga. Updating the database and publishing a message must be done atomically, otherwise the system may end up in an inconsistent state. This can happen if, for example, after committing changes to the database, the message is not sent due to network failure. The Transitional Outbox or Event Sourcing pattern can be used to ensure data consistency. The article is devoted to research the features of using these patterns when implementing distributed transactions using Saga, identifying the advantages and disadvantages of each approach. Event Sourcing allows you to save the history of changes in the state of an object, play back events to restore its state at a certain point in time. The disadvantage of this pattern is that it is difficult to learn. When using complex database queries, in combination with Event Sourcing you should use the CQRS pattern. The paper presents a microservices-based application architecture built using the Saga and Outbox design patterns. Services interact with each other asynchronously using Apache Kafka and Debezium connectors, which monitor changes in the databases and transmit messages to the broker. Services receive messages from the broker immediately after publication.

References

Richardson Ch. Microservices Patterns. Manning Publications, 2019. 520 p.

Бугаєва І.Г., Розум М.В., Ларін Д.Г., Ткаченко М.Г. Управління транзакціями в мікросервісній архітектурі. Таврійський науковий вісник. Серія: Технічні науки. 2023. № 2. С. 3–13.

Richardson, Ch. Pattern: Transactional outbox. URL: https:// microservices.io/patterns/data/transactional-outbox.html (дата звернення: 05.06.2023).

Fowler M. Event Sourcing. 2005. URL: https://martinfowler.com/eaaDev/EventSourcing.html (дата звернення: 20.06.2023).

Overeem, M., Spoor, M., Jansen, S. The dark side of event sourcing: Managing data conversion. IEEE 24th International Conference on Software Analysis, Evolution and Reengineering. 2017. DOI:10.1109/SANER. 2017.7884621

Overeem M., Spoor M., Jansen S., Brinkkemper S. An empirical characterization of event sourced systems and their schema evolution – Lessons from industry. The Journal of Systems and Software. 2021. Vol. 178. DOI:10.1016/j.jss.2021.110970.

Scott D., Gamov V., Klein D. Kafka in Action. Manning Publications, 2022. 272 p.

Debezium. URL: https://debezium.io/ (дата звернення: 11.07.2023).

Published

2023-11-09

How to Cite

Бугаєва, І. Г. (2023). SAGA IMPLEMENTATION USING THE OUTBOX PATTERN. Таuridа Scientific Herald. Series: Technical Sciences, (4), 32-39. https://doi.org/10.32782/tnv-tech.2023.4.4

Issue

Section

COMPUTER SCIENCE AND INFORMATION TECHNOLOGY