What types of distributed transactions exist?
sobes.tech AI
Answer from AI
In distributed systems, there are several types of distributed transactions that ensure data consistency when performing operations on multiple nodes:
-
Two-Phase Commit (2PC) — a classic protocol where the coordinator first asks all participants for readiness to commit, and then either confirms the commit or rolls back the transaction. It ensures atomicity but can lock resources.
-
Three-Phase Commit (3PC) — an extension of 2PC with an additional phase to reduce the risk of blocking and increase fault tolerance.
-
Compensating Transactions — instead of locking resources, transactions are executed locally, and in case of an error, compensating operations are launched to rollback changes. Often used in microservices.
-
Timestamp Ordering Transactions — operations are ordered by time to ensure consistency.
-
Optimistic Transactions — assume no conflicts and check for conflicts only at commit time, rolling back if necessary.
The choice of type depends on the requirements for consistency, performance, and fault tolerance of the system.