What is a Distributed Transaction?
You'll learn: What distributed transactions are and why coordinating changes across multiple systems creates unique challenges.
The Core Problem
A distributed transaction is a single logical operation that must update data across multiple independent databases or services while maintaining consistency guarantees. Unlike a local transaction (which runs entirely within one database), a distributed transaction must coordinate changes across network boundaries.
Think of it like coordinating a bank transfer between two different banks. The money must leave one account AND arrive in the other—both steps must succeed together, or both must fail. Neither bank can act independently without risking lost or duplicated money.
Why This is Challenging
When a transaction spans multiple systems, several problems emerge:
Network Failures: Services can become unreachable mid-transaction. Did the remote database commit? Timeout? The coordinator may never know.
Partial Failures: One system might commit successfully while another fails. Now you have inconsistent state across services.
Coordination Overhead: All participating systems must agree on whether to commit or abort. This requires multiple network round-trips and blocking resources.
Concurrent Conflicts: Different distributed transactions might touch the same data in different orders across services, creating deadlocks.
A Simple Example
Imagine an e-commerce order that must:
- Reserve inventory (Inventory Service database)
- Charge payment (Payment Service database)
- Create shipping label (Shipping Service database)
All three must succeed together—partial success leaves your system in an inconsistent, broken state.
Key Takeaway: Distributed transactions coordinate changes across multiple independent systems while guaranteeing consistency, but face significant challenges from network failures, partial commits, and coordination overhead that don't exist in single-database transactions.