TRANSACTION MANAGEMENT IN MICROSERVICE ARCHITECTURE
DOI:
https://doi.org/10.32782/tnv-tech.2023.2.1Keywords:
microservices, microservice architecture, distributed transactions, data consistency, two-phase commit, Saga design patternAbstract
The use of microservice architecture is a popular approach to the development of modern software systems. Microservices are used in large Internet projects serving a large number of users. Applications with microservice architecture have many advantages such as high availability, fault tolerance, flexibility, scalability. Along with the advantages, this approach also has disadvantages. In a distributed system consisting of many services, managing transactions spanning multiple services is a complex task. Since microservices are loosely coupled and the data used by a distributed transaction is stored on different nodes in the network, there is a problem of data consistency. The purpose of the article is to explore ways to manage transactions in microservices and ensure data consistency, identifying the advantages and disadvantages of applying existing design patterns. This article discusses the use of the 2PC two-phase commit protocol and the Saga design pattern. 2PC is a robust data consistency protocol for microservices. But it is a form of synchronous communication that results in microservices being coupled at runtime, which has a significant impact on the availability of the application. If high availability of the application is a priority requirement, then it is better to choose the Saga design pattern as a basis for development. It solves the problem of executing transactions spanning multiple services. To ensure data consistency, Saga is used in conjunction with the Event sourcing or Transactional Outbox pattern. Using the choreography-based saga pattern provides better service performance compared to orchestration. It is better to use it for scenarios in which response time is critical, the number of services involved in a distributed transaction is small. The orchestration-based pattern is slower than choreography, but is the best choice for handling complex transaction scenarios.
References
Richardson Ch. Microservices patterns. Manning Publications, 2019. 520 p.
Newman S. Building Microservices: Designing Fine-Grained Systems. O’Reilly Media, 2015. 280 p.
Бугаєва І.Г., Розум М.В. Реалізація міжпроцесної взаємодії в мікросервісній архітектурі. Вiсник Одеського національного морського унiверситету: Зб. наук. праць. 2022. № 1(67). С. 81–89.
Rudrabhatla Ch. K. Comparison of Event Choreography and Orchestration Techniques in Microservice Architecture. International Journal of Advanced Computer Science and Applications. 2018. Vol. 9, No. 8.
Kristianto H., Zahra A. Performance analysis of choreography and orchestration in microservices architecture. Journal of Theoretical and Applied Information Technology. 2021. Vol. 99, No.18.
Harding R., Aken D. V., Pavlo A., Stonebraker M. An Evaluation of Distributed Concurrency Control. Proceedings of the VLDB Endowment. 2017. Vol. 10, No. 5.
Garcia-Molina H., Salem K. SAGAS. Proceedings of the 1987 ACM SIGMOD international conference on Management of data. 1987. P. 249–259.