Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the value and principle of distributed transaction GTS

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what is the value and principle of distributed transaction GTS". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the value and principle of distributed transaction GTS".

GTS's score of Singles' Day this year

Behind this year's 268.4 billion, there is a quiet, low-key and almost forgotten middleware cloud product, GTS (Global transaction Service, Global Transaction Service), which has passed the fifth "big test" since its birth in 2014.

From November 1 to 12, 2019, the average daily number of distributed transactions handled by GTS reached 100 million, and the daily peak TPS reached 10,000.

The most important significance behind this is that the achievement is achieved under the premise of bringing zero burden to the design and development of business applications.

The value of GTS

With the development of enterprises, enterprise business architecture is faced with the distribution of data and services, and it is almost inevitable to encounter the problem of data consistency brought about by distributed architecture.

GTS creatively separates the distributed transaction problem from the business, manages it as an independent technical aspect, and provides a simple, easy-to-use and efficient distributed transaction solution for applications built on the cloud in the form of services.

The value that GTS brings to business applications is reflected in the following aspects:

Reduced architecture complexity: the technical problem of distributed transactions is solved by converging to the services provided by GTS.

Reduced design and development costs: the design and development of business logic does not need to do anything extra to invade the business as to whether or not distributed transactions are involved.

Faster project delivery and iteration: thanks to the above two points, the project can be delivered and iterated quickly. GTS gives business applications the ability to try and make mistakes quickly, which is particularly important in this era of rapidly changing business opportunities.

Imagine a typical growth path for cloud-native enterprise applications:

1.0: single application, quickly online, this time does not involve distributed transactions at all.

2.0: a single database cannot be supported, and the data is distributed to multiple databases, resulting in distributed transaction problems.

3.0: micro-service, which further generates distributed transactions across services.

4. 0: cross-application integration becomes the platform of SaaS or FaaS, which leads to distributed transaction problems on a larger scale.

Based on the distributed transaction service provided by GTS, the problem of data consistency in different scenarios in different stages of enterprise development can be solved in one stop. This allows the business to grow smoothly and naturally, like building blocks.

As can be seen from the above example, GTS actually provides distributed transaction (or data consistency in distributed scenarios) as a cloud native service to applications growing on the cloud, so that distributed transaction is no longer a headache for business, but a service capability that can be flexibly scaled and accessed on demand.

The principle and Innovation of GTS

Next, we will introduce the principle and innovation of GTS from several aspects.

First, GTS defines a distributed transaction as a global transaction consisting of several local transactions (branches). All branches managed by the global transaction will be guaranteed to succeed or be rolled back together under the coordination of the coordinator.

Secondly, GTS defines a transaction model, which models the whole global transaction process as a cooperation mechanism among TM, RM and TC components.

Transaction Coordinator (TC): transaction coordinator, which maintains the running state of global transactions and is responsible for coordinating and driving the commit or rollback of global transactions.

Transaction Manager (TM): controls the boundaries of a global transaction, is responsible for opening a global transaction, and ultimately initiates a global commit or global rollback resolution.

Resource Manager (RM): control branch transactions, responsible for branch registration, status reporting, and receive instructions from the transaction coordinator to drive the commit and rollback of branch (local) transactions.

A typical distributed transaction process:

TM requests TC to open a global transaction, and the global transaction is created successfully and a globally unique XID is generated.

XID propagates in the context of the microservice invocation link.

RM registers branch transactions with TC and puts them under the jurisdiction of XID corresponding global transactions.

TM initiates a global commit or rollback resolution against XID to TC.

TC schedules all branch transactions under the jurisdiction of XID to complete commit or rollback requests.

Third, GTS creatively implements a non-intrusive automatic compensation rollback mechanism based on SQL parsing. This mechanism is named Auto Transaction (AT) mode by GTS. The basic working principles are as follows:

GTS divides the global transaction into two phases: the execution phase and the completion phase.

Execution phase:

Through parsing the business SQL, the JDBC data source agent of GTS organizes the data mirroring of the business data before and after the update into a rollback log, and makes use of the ACID feature of the local transaction to submit the update of the business data and the writing of the rollback log in the same local transaction.

In this way, it is guaranteed that there must be a corresponding rollback log for the update of any submitted business data.

Based on this mechanism, the local transaction of the branch can be committed during the execution phase of the global transaction, and the resources locked by the local transaction can be released immediately.

Completion phase:

If the resolution issued by TM is a global commit, and the branch transaction has completed the commit at this time, there is no need for synchronous coordination processing (only the rollback log needs to be cleaned asynchronously), and the completion phase can be completed very quickly.

If the resolution issued by TM is a global rollback, RM receives a rollback request from the coordinator, finds the corresponding rollback log record through XID and Branch ID, generates a reverse update SQL through the rollback record and executes it to complete the branch rollback.

Finally, GTS implements a highly available service that rejects a single point of failure through transaction coordinator clustering and fault tolerance to business application nodes.

On the one hand, the GTS service cluster mechanism ensures the downtime of any service node and can be seamlessly taken over by other nodes. On the other hand, when the downtime of any node is applied, the request of the corresponding transaction branch will also be routed to other nodes connected to the same database, which does not affect the complete execution of the global transaction.

Distributed transaction Mode Fusion and Standardization (Protection)

So far, there is no technical solution for distributed transactions that can meet the problems of all scenarios. GTS's AT mode is suitable for most common scenarios, but there are still some scenarios that are more suitable for using other distributed transaction solutions in the industry. GTS will integrate all kinds of solutions into the cloud service framework provided by GTS to provide one-stop distributed transaction services for cloud native applications.

This is the transaction framework abstracted by GTS. Through this abstraction, distributed transactions can be separated from the overall architecture to form a separate technical aspect that can be provided to the application as a service.

To put it simply, the distributed transaction problem of the application based on this framework converges to the branch transaction mechanism based on RM and the stable and reliable service provided by TC. Divide and rule can solve the problem more effectively.

At the current distributed application level, there are four most representative transaction modes, namely, AT, TCC, Saga and XA, each of which has its own advantages and disadvantages and applicable scenarios.

The pros and cons of the four transaction modes and the mapping in GTS's transaction framework are listed below.

AT

Advantages: business is non-intrusive; lightweight, does not rely on the advanced features of the database; scenarios with fewer rollbacks have high performance.

Disadvantages: the isolation is not high, it can only be supported close to the level of read submitted at present, and the cost of implementation will be very high with a higher isolation level.

TCC

Advantages: it can be used in a wide range of scenarios; isolation and performance can be optimized.

Disadvantage: the business is very intrusive.

Saga

Advantages: long-term business.

Disadvantages: a certain degree of business invasion; poor isolation.

XA

Advantages: no business intrusion; good isolation.

Disadvantage: blocking protocol.

GTS and Open Source

In order to better build a cloud-native distributed transaction standard, GTS chose open source in early 2019 and launched the open source project SEATA (formerly known as FESCAR). The project has been open source for less than a year, and the number of harvested STAR has exceeded 12000, and the number of Contributor has exceeded 120. it has been widely concerned and recognized by the community.

Distributed transaction has always been a worldwide problem. I hope that through the open platform of SEATA, we can gather the wisdom of the world to give a satisfactory answer to this problem.

Further, GTS converts this answer paper into an efficient, stable and reliable service on Aliyun, which can be given to the majority of cloud native developers.

Thank you for your reading, the above is the content of "what is the value and principle of distributed transaction GTS". After the study of this article, I believe you have a deeper understanding of what is the value and principle of distributed transaction GTS. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report