Автоматичне відновлення та ідентифікація стану під час застосування шаблону Saga для трансакційного виконання операцій, пов’язаних з базами даних в мікросервісному середовищі
Вантажиться...
Дата
2025
Назва журналу
Номер ISSN
Назва тому
Видавець
Хмельницький національний університет
Анотація
Під час використання мікросервісної архітектури шаблон Saga виступає важливим способом забезпечення узгодженості даних без потреби в централізованих або розподілених трансакціях у класичному сенсі. Його суть полягає в декомпозиції складного бізнес-процесу на перелік послідовних локальних – для кожного
мікросервіса – трансакцій, кожна з яких виконується автономно в межах контексту свого сервісу.
На відміну від трансакцій в межах монолітної архітектури, де виконується один цілісний процес, що завершується комітом в межах бази даних; у Saga кожна локальна операція запускається після завершення
попередньої. У випадку будь-яких помилок виконання,, вона супроводжується запуском компенсаційних дій. Це дозволяє досягати поступової узгодженості в асинхронному середовищі притаманної міжсервісній комунікації.
Зі зростанням популярності застосування мікросервісної архітектури також зростає складність координації трансакцій, особливо в умовах динамічного оновлення компонентів і гнучкої масштабованості. Шаблон Saga забезпечує досягнення поступової узгодженості, однак його ефективність залежить від того, наскільки глибоко враховано семантичну роль кожного кроку бізнес-процесу. Саме Saga розглядається не лише як технічний шаблон, а як частина загальної логіки доменно-орієнтованого проєктування, де кожна трансакція
є подією з визначеними наслідками для всієї системи.
Однак, така асинхронність і створює фундаментальні труднощі в контролі за станом виконання всієї саги, як цілісного процесу. У певний момент часу, система не має уявлення про те, на якому етапі перебуває трансакція, і які дії було успішно завершено. Цей ефект підсилюється розподіленістю – кожен сервіс оперує
власними локальними даними, незалежним кодом й ізольованим життєвим циклом. Наслідком, у цьому випадку, є централізоване ведення статусу процесу, який стає неочевидним і неоднозначним, при умові, що не було закладено додаткової спеціальної логіки для передбачення проблемних випадків.
У результаті досліджень було визначено та запропоновано способи автоматизації управління Saga та зменшення необхідності у ручному втручанні в процес виконання під час настання збоїв.
When using a microservice architecture, the Saga pattern serves as an important method for ensuring data consistency without the need for centralized or distributed transactions in the classical sense. Its essence lies in decomposing a complex business process into a list of sequential local — for each microservice — transactions, each of which is executed autonomously within the context of its own service. Unlike transactions within a monolithic architecture, where a single integral process is executed and completed with a commit within the database; in a Saga, each local operation is launched after the completion of the previous one. In case of its failure in the form of any execution errors, it is accompanied by the launch of compensating actions. This allows for gradual consistency to be achieved in the asynchronous environment inherent to inter-service communication. With microservice architecture's growing popularity, transaction coordination complexity is also increasing, especially under dynamic component updates and flexible scalability. The Saga pattern enables the achievement of gradual consistency; however, its effectiveness depends on the extent to which the semantic role of each business process step is considered. Saga is thus viewed not only as a technical pattern but as an integral part of domain-driven design logic, where each transaction represents an event with defined consequences for the entire system. However, this very asynchrony creates fundamental difficulties in controlling the execution state of the entire Saga as an integral process. At a certain point in time, the system has no explicit understanding of which stage the transaction is at and which actions have been successfully completed. This effect is attributed to the distributed nature — that is, each service operates with its own local data, independent code, and isolated lifecycle. As a consequence, in this case, centralized tracking of the process status becomes non-obvious and ambiguous, provided that no additional special logic has been embedded to anticipate problematic scenarios. As a result of the research, methods for automating the management of the Saga and reducing the need for manual intervention during execution failures have been identified and proposed.
When using a microservice architecture, the Saga pattern serves as an important method for ensuring data consistency without the need for centralized or distributed transactions in the classical sense. Its essence lies in decomposing a complex business process into a list of sequential local — for each microservice — transactions, each of which is executed autonomously within the context of its own service. Unlike transactions within a monolithic architecture, where a single integral process is executed and completed with a commit within the database; in a Saga, each local operation is launched after the completion of the previous one. In case of its failure in the form of any execution errors, it is accompanied by the launch of compensating actions. This allows for gradual consistency to be achieved in the asynchronous environment inherent to inter-service communication. With microservice architecture's growing popularity, transaction coordination complexity is also increasing, especially under dynamic component updates and flexible scalability. The Saga pattern enables the achievement of gradual consistency; however, its effectiveness depends on the extent to which the semantic role of each business process step is considered. Saga is thus viewed not only as a technical pattern but as an integral part of domain-driven design logic, where each transaction represents an event with defined consequences for the entire system. However, this very asynchrony creates fundamental difficulties in controlling the execution state of the entire Saga as an integral process. At a certain point in time, the system has no explicit understanding of which stage the transaction is at and which actions have been successfully completed. This effect is attributed to the distributed nature — that is, each service operates with its own local data, independent code, and isolated lifecycle. As a consequence, in this case, centralized tracking of the process status becomes non-obvious and ambiguous, provided that no additional special logic has been embedded to anticipate problematic scenarios. As a result of the research, methods for automating the management of the Saga and reducing the need for manual intervention during execution failures have been identified and proposed.
Опис
Ключові слова
мікросервіна архітектура, трансакція, Saga, бази даних, відновлення, контроль стану, автоматизація, відновлення, microservice architecture, transaction, Saga, database, compensation, recovery, state control, automation, restoration
Бібліографічний опис
Супрун П. Автоматичне відновлення та ідентифікація стану під час застосування шаблону Saga для трансакційного виконання операцій, пов’язаних з базами даних в мікросервісному середовищі / П. Супрун, Н. Праворська // Herald of Khmelnytskyi National University. Technical Sciences. – 2025. – Vol. 357, No. 5.2. – P. 12-18.