How Fescar Simplifies Distributed Transactions in Microservices
This article introduces Fescar, Alibaba's open‑source distributed transaction framework for microservices, explains the challenges of global transactions, outlines its architecture and components, and reviews its evolution from TXC to GTS to Fescar.
1. What is Fescar
FESCAR (Fast & Easy Commit And Rollback) is a high‑performance, easy‑to‑use distributed transaction solution designed for microservice architectures, aiming to provide simple and fast transaction commit and rollback.
2. Distributed Transaction Issues in Microservice Architecture
In a monolithic application, multiple modules share a single local data source, making local transactions sufficient for data consistency. In microservices, each module becomes an independent service with its own database, so local transactions can only guarantee consistency within a single service, not across the entire application.
Similarly, the global transaction consists of multiple branch transactions, usually local transactions, which need coordination.
3. Fescar Mechanism
Fescar addresses the above problems with three core components:
Transaction Coordinator (TC): Maintains the state of global and branch transactions and drives commit or rollback of the global transaction.
Transaction Manager (TM): Defines the scope of a global transaction, initiating, committing, or rolling back it.
Resource Manager (RM): Manages branch transaction resources, registers branches with TC, reports their status, and drives branch commit or rollback.
The typical lifecycle of a distributed transaction managed by Fescar is:
TM requests TC to start a new global transaction, TC generates a global transaction ID (XID).
The XID propagates through the microservice call chain.
RM registers the local transaction as a branch of the XID in TC.
TM requests TC to commit or rollback the global transaction identified by the XID.
TC drives all branch transactions under the XID to complete commit or rollback.
4. Evolution History
TXC (Taobao Transaction Constructor) started in 2014 by Alibaba's middleware team to solve distributed transaction problems caused by the shift to microservices.
GTS (Global Transaction Service) was the 2016 product release of TXC.
Fescar was open‑sourced in 2019 based on TXC/GTS.
5. What Next?
Given its high performance and ease of use, developers are encouraged to try Fescar for managing distributed transactions in their microservice systems.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
