Distributed Transactions Part 1: The Death of ACID
In a monolith, data consistency is easy. You wrap your code in a database transaction, and the database guarantees that either everything happens or nothing happens. In microservices, this "magic" disappears.
1. The Monolith's False Safety
When you have one database, ACID (Atomicity, Consistency, Isolation, Durability) is a local property. But as soon as you have two databases, or a database and a message queue, you hit the Dual Write Problem.
2. CAP vs. PACELC
You likely know CAP, but senior architects look at PACELC.
- Partition (P), choose between Availability (A) and Consistency (C).
- Else (E), choose between Latency (L) and Consistency (C).
3. The Production Reality
In a distributed system, you cannot have 100% consistency and 100% availability with low latency. You must design for Eventual Consistency.
