Font Size: a A A

Optimization And Implementation Of Distributed Transactions Based On MongoDB

Posted on:2022-04-07Degree:MasterType:Thesis
Country:ChinaCandidate:J LaiFull Text:PDF
GTID:2518306524993579Subject:Computer technology
Abstract/Summary:PDF Full Text Request
With the growing volume of enterprise data,the enterprise development application architecture evolves to microservice architecture,which slices business modules into ap-plication services and ensures the consistency of data between different application ser-vices through distributed transactions.However,traditional distributed transactions are difficult to be applied in microservice architecture,so it is important to study the dis-tributed transactions based on microservice architecture.Compared with traditional relational databases,MongoDB's unique design of replica sets and sharded clusters makes it have better scalability and availability.However,Mon-go DB locks resources for a long time during one global transaction,which affects the performance of business systems.To address the above problems,the paper implements a final consistent distributed transaction applicable to the microservice architecture based on BASE theory,which remedies the deficiency of MongoDB distributed transaction locking resources for a long time.The two-phase commit protocol is optimized through a logging compensation mechanism.In one phase,SQL interception and parsing is performed by participants,mapped to MongoDB statements,and the current state is registered with the coordinator by building a rollback log through the statements.After successful registra-tion,the update is committed locally and the log is saved,releasing the lock resources.In the second phase,the coordinator uses an asynchronous queue to process the status of the transactions committed by the participants.If all participants commit successfully,the participants are notified to delete the rollback log asynchronously? if any participant fails to commit,the participants are notified to reverse the compensation rollback based on the log.The above optimization strategy is deployed between the application service and MongoDB in the form of a final consistency distributed transaction plugin.Finally,basic functional tests as well as overall performance tests were conducted for the plug-in as well as the native MongoDB distributed transaction.The experimental results prove that the Final Consistency Distributed Plugin has better performance and availability in the microservice architecture.
Keywords/Search Tags:MongoDB, distributed transaction, eventually consistent, microservice
PDF Full Text Request
Related items