Enhancing Saga Pattern for Distributed Transactions within a Microservices Architecture
The saga pattern manages transactions and maintains data consistency across distributed microservices via utilizing local sequential transactions that update each service and publish messages to trigger the next ones. Failure by one transaction causes the execution of compensating transactions that...
Main Authors: | , , |
---|---|
Format: | Article |
Language: | English |
Published: |
MDPI AG
2022-06-01
|
Series: | Applied Sciences |
Subjects: | |
Online Access: | https://www.mdpi.com/2076-3417/12/12/6242 |
_version_ | 1797490238159847424 |
---|---|
author | Eman Daraghmi Cheng-Pu Zhang Shyan-Ming Yuan |
author_facet | Eman Daraghmi Cheng-Pu Zhang Shyan-Ming Yuan |
author_sort | Eman Daraghmi |
collection | DOAJ |
description | The saga pattern manages transactions and maintains data consistency across distributed microservices via utilizing local sequential transactions that update each service and publish messages to trigger the next ones. Failure by one transaction causes the execution of compensating transactions that counteract the preceding one. However, saga lacks isolation, meaning that reading and writing data from an incomplete transaction is allowed. Therefore, this research proposes an enhanced saga pattern that resolves the lack of isolation issue via the use of the quota cache and the commit-sync service. Some transactions will be transferred from the database layer to the memory layer. Thus, no wrong commit to the main database will occur. If a microservice fails to be completed, the other microservices will run compensation transactions to rollback the changes that only affect the cache layer instead of the database layer. Database commit will be performed when all transactions are completed successfully. A lightweight microservices-based e-commerce system was implemented for comparison. Experiments were conducted for validation and evaluation. Results demonstrate that the proposal has the capability of resolving the lack of isolation. Results indicate that the proposal achieves better performance not only in typical cases but also in the scenario that needs to handle exceptions. |
first_indexed | 2024-03-10T00:29:09Z |
format | Article |
id | doaj.art-f7f93092df4f42c19461971554140352 |
institution | Directory Open Access Journal |
issn | 2076-3417 |
language | English |
last_indexed | 2024-03-10T00:29:09Z |
publishDate | 2022-06-01 |
publisher | MDPI AG |
record_format | Article |
series | Applied Sciences |
spelling | doaj.art-f7f93092df4f42c194619715541403522023-11-23T15:30:13ZengMDPI AGApplied Sciences2076-34172022-06-011212624210.3390/app12126242Enhancing Saga Pattern for Distributed Transactions within a Microservices ArchitectureEman Daraghmi0Cheng-Pu Zhang1Shyan-Ming Yuan2Applied Computing Department, Palestine Technical University Kadoorie, Tulkarm p3050950, PalestineComputer Science Department, National Yang Ming Chiao Tung University, Hsinchu 300, TaiwanComputer Science Department, National Yang Ming Chiao Tung University, Hsinchu 300, TaiwanThe saga pattern manages transactions and maintains data consistency across distributed microservices via utilizing local sequential transactions that update each service and publish messages to trigger the next ones. Failure by one transaction causes the execution of compensating transactions that counteract the preceding one. However, saga lacks isolation, meaning that reading and writing data from an incomplete transaction is allowed. Therefore, this research proposes an enhanced saga pattern that resolves the lack of isolation issue via the use of the quota cache and the commit-sync service. Some transactions will be transferred from the database layer to the memory layer. Thus, no wrong commit to the main database will occur. If a microservice fails to be completed, the other microservices will run compensation transactions to rollback the changes that only affect the cache layer instead of the database layer. Database commit will be performed when all transactions are completed successfully. A lightweight microservices-based e-commerce system was implemented for comparison. Experiments were conducted for validation and evaluation. Results demonstrate that the proposal has the capability of resolving the lack of isolation. Results indicate that the proposal achieves better performance not only in typical cases but also in the scenario that needs to handle exceptions.https://www.mdpi.com/2076-3417/12/12/6242microservicesaga patterndistributed transactionread isolation |
spellingShingle | Eman Daraghmi Cheng-Pu Zhang Shyan-Ming Yuan Enhancing Saga Pattern for Distributed Transactions within a Microservices Architecture Applied Sciences microservice saga pattern distributed transaction read isolation |
title | Enhancing Saga Pattern for Distributed Transactions within a Microservices Architecture |
title_full | Enhancing Saga Pattern for Distributed Transactions within a Microservices Architecture |
title_fullStr | Enhancing Saga Pattern for Distributed Transactions within a Microservices Architecture |
title_full_unstemmed | Enhancing Saga Pattern for Distributed Transactions within a Microservices Architecture |
title_short | Enhancing Saga Pattern for Distributed Transactions within a Microservices Architecture |
title_sort | enhancing saga pattern for distributed transactions within a microservices architecture |
topic | microservice saga pattern distributed transaction read isolation |
url | https://www.mdpi.com/2076-3417/12/12/6242 |
work_keys_str_mv | AT emandaraghmi enhancingsagapatternfordistributedtransactionswithinamicroservicesarchitecture AT chengpuzhang enhancingsagapatternfordistributedtransactionswithinamicroservicesarchitecture AT shyanmingyuan enhancingsagapatternfordistributedtransactionswithinamicroservicesarchitecture |