Distributed Transactions in Microservice Architecture: Informed Decision-making Strategies

2024;
: pp. 449 - 459
1
Lviv Polytechnic National University, Software department, Lviv, Ukraine
2
Lviv Polytechnik National University

The emergence of microservice architecture has revolutionized software development practices by decentralizing components, facilitating scalability, and enabling agility in system design and deployment. There are some benefits of incorporating microservices instead of a single server, however, distributed components introduce extra constraints and complexities in maintaining data consistency as well. As microservices interact independently, coordinating data updates across multiple services becomes challenging, particularly in scenarios where transactional integrity is required. Distributed transactions are one of the solutions for ensuring data consistency across services. Regardless of effectiveness distributed transactions entail different trade-offs and performance implications. Those trade-offs are not always justified. This study highlights the need for a nuanced understanding of distributed transactions in microservices by revisiting challenges in managing distributed transactions within data storage systems. It also represents existing solutions to the different distributed transaction methods. In this paper, through experiments comparing microservices and monolithic systems, the impact of distributed transactions on system performance is evaluated, giving intuition about consequences when a single data source transaction is migrated to the distributed environment. This research also contributes to enhancing understanding and decision-making regarding the utilization of distributed transactions in a microservices architecture. Ultimately, this paper presents an optimized decision-framework for the application of distributed transactions in microservices architecture, aiming to simplify and expedite processes of software architecture for software engineers, solution architects, and developers.

  1. Bacon, D., Kogan, E., Lloyd, A., Melnik, S., Rao, R., Shue, D., Taylor, C., Holst, M., Woodford, D., Bales, N., Bruno, N., Cooper, B., Dickinson, A., Fikes, A., Fraser, C., Gubarev, A., Joshi, M. (2017). Spanner: Becoming a SQL system. Proceedings of the 2017 ACM International Conference on Management of Data, 331–343. https://doi.org/10.1145/3035918.3056103
  2. Barthels, C., Müller, I., Taranov, K., Alonso, G., & Hoefler, T. (2019). Strong consistency is not hard to get: Two-phase locking and two-phase commit on thousands of cores. Proceedings of the VLDB Endowment, 12(13), 2325–2338.    https://doi.org/10.14778/3358701.3358702
  3. Bashtovyi, A., & Fechan, A. (2023). Change data capture for migration to event-driven microservices case study. https://doi.org/10.1109/CSIT61576.2023.10324262
  4. Bharati, R. D., & Attar, V. Z. (2018). A comprehensive survey on distributed transactions based data partitioning. 2018 International Conference on Current Trends towards Converging Technologies (ICCT), 1–5. https://doi.org/10.1109/ICCUBEA.2018.8697589
  5. Binildas, C. (2019). Transactions and microservices. In Practical microservices architectural patterns, 483–541. Apress. https://doi.org/10.1007/978-1-4842-4501-9_14
  6. Daraghmi, E., Yuan, S. M., & Zhang, C. P. (2022). Enhancing saga pattern for distributed transactions within a microservices architecture. Applied Sciences, 12(12), 6242. https://doi.org/10.3390/app12126242
  7. Dürr, K., Lichtenthaeler, R., & Wirtz, G. (2022). Saga pattern technologies: A criteria-based evaluation. In Proceedings of the 17th International Conference on Software Technologies, 141–148. SciTePress. https://doi.org/10.5220/0010999400003200
  8. Fan, P., Liu, J., Yin, W., & Wang, H. (2020). 2PC*: A distributed transaction concurrency control protocol of multi-microservice based on cloud computing platform. Journal of Cloud Computing, 9(1), Article 11. https://doi.org/10.1186/s13677-020-00183-w
  9. Helland P.(2017). Life beyond distributed transactions. Commun. ACM, 60, 2, 46–54. https://doi.org/10.1145/3009826
  10. Janssen, T. (n.d.). Distributed transactions – Don’t use them for microservices. Thorben Janssen. Retrieved April 1, 2024, from https://thorben-janssen.com/distributed-transactions-microservices/
  11. Kleppmann, M. (2017). Designing Data-Intensive Applications (1st ed.). O’Reilly Media, Inc.
  12. Limón, X., Guerra-Hernández, A., Sanchez G., A., & Pérez-Arriaga, J. C. (2018). SagaMAS: A software framework for distributed transactions in the microservice architecture. In Proceedings of the 6th International Conference in Software Engineering Research and Innovation, 50–58. IEEE. https://doi.org/10.1109/CONISOFT.2018.8645853
  13. Lin, Q., Chang, P., Chen, G., Ooi, B. C., Tan, K.-L., & Wang, Z. (2016). Towards a non-2PC transaction management in distributed database systems. In Proceedings of the 2016 International Conference on Management of Data, 1659–1674. Association for Computing Machinery. https://doi.org/10.1145/2882903.2882923
  14. Munonye, K. & Martinek, P. (2020). Enhancing Performance of Distributed Transactions in Microservices via Buffered Serialization. Journal of Web Engineering. https://doi.org/10.13052/jwe1540-9589.1956.
  15. MySQL NDB Cluster CGE. (n.d.) MySQL. Retrieved April 1, 2024, from https://www.mysql.com/products/cluster/
  16. Richardson, C. (n.d.). Pattern: Database per service. Microservice Architecture Retrieved April 1, 2024, from     https://microservices.io/patterns/data/database-per-service.html
  17. Ruan, P., Dinh, T. T. A., Loghin, D., Zhang, M., Chen, G., Lin, Q., & Ooi, B. C. (2021). Blockchains vs. distributed databases: Dichotomy and fusion. In Proceedings of the 2021 International Conference on Management of Data, 1504–1517. Association for Computing Machinery. https://doi.org/10.1145/3448016.3452789
  18. Sekhar, R. R. (2020). Microservices, Saga Pattern and Event Sourcing: A Survey. International Research Journal of Engineering and Technology, 7(5), 633–636. https://www.irjet.net/archives/V7/i5/IRJET-V7I5124.pdf
  19. Shamis, A., Renzelmann, M., Novakovic, S., Chatzopoulos, G., Dragojević, A., Narayanan, D., & Castro, M. (2019). Fast general distributed transactions with opacity. In Proceedings of the 2019 International Conference on Management of Data (SIGMOD '19), 433–448. Association for Computing Machinery. https://doi.org/10.1145/3299869.3300069
  20. Shi, L., Wang, K., Li, M., Tong, J., Qiao, H., & Jiang, Y. (2023). Research on distributed relational database based on MySQL. Other Conferences.
  21. Štefanko, M., Chaloupka, O., & Rossi, B. (2019). The saga pattern in a reactive microservices environment. In Proceedings of the 14th International Conference on Software Technologies, 483–490. SciTePress. https://doi.org/10.5220/0007918704830490
  22. Transactions. (n. d.). MongoDB. Retrieved April 1, 2024, from https://www.mongodb.com/docs/manual/core/transactions/
  23. Wu, Y., & Liang, Z. (2018). Implementation of distributed XA transactions in MyCat based on table broadcasting mechanism. In 2018 IEEE/ACM 5th International Conference on Big Data Computing Applications and Technologies (BDCAT), 215–216. IEEE. https://doi.org/10.1109/BDCAT.2018.00038
  24. Yan, X., Yang, L., Zhang, H., Lin, X., Wong, B., Salem, K., & Brecht, T. (2018). Carousel: Low-latency transaction processing for globally-distributed data. In Proceedings of the 2018 International Conference on Management of Data, 231–243. Association for Computing Machinery. https://doi.org/10.1145/3183713.3196912
  25. Zamanian, E., Kraska, T., Binnig, C., & Harris, T. (2016). The End of a Myth: Distributed Transactions Can Scale. Proceedings of the VLDB Endowment, 10(6), 483–541. https://doi.org/10.14778/3055330.3055335
  26. Zhang, G., Ren, K., Ahn, J. S., & Romdhane, S. B. (2019). GRIT: Consistent Distributed Transactions Across Polyglot Microservices with Multiple Databases. https://doi.org/10.1109/ICDE.2019.00230
  27. Zhang, Q., Li, J., Zhao, H., Xu, Q., Lu, W., Xiao, J., Han, F., Yang, C., & Du, X. (2023). Efficient distributed transaction processing in heterogeneous networks. Proceedings of the VLDB Endowment, 16(5), 1372– 1385.    https://doi.org/10.14778/3583140.3583153
  28. Zhu, T., Guo, J., Zhou, H., Zhou, X., & Zhou, A.-Y. (2018). Consistency and availability in distributed database systems. Ruan Jian Xue Bao/Journal of Software, 29(1), 131–149. https://doi.org/10.13328/j.cnki.jos.005433