How does the CAP theorem force design decisions like eventual consistency and compensating transactions in microservices?
Last updated
CAP: network partitions are unavoidable, so during one you must choose consistency or availability. Microservices usually choose availability (AP).
AP means data is temporarily out of sync (eventual consistency). Without atomic cross-service commits, failures are undone with compensating transactions.
The choice is per operation: use strong consistency (CP) for critical invariants like payments, and eventual consistency elsewhere.
- https://www.geeksforgeeks.org/operating-systems/what-is-a-distributed-transaction/
- https://www.geeksforgeeks.org/system-design/what-is-eventual-consistency-between-microservices/
- https://www.geeksforgeeks.org/system-design/difference-between-saga-pattern-and-2-phase-commit-in-microservices/
- https://www.geeksforgeeks.org/system-design/saga-design-pattern/