Alternative: Idempotent Operations
What you'll learn: How designing operations that can be safely retried eliminates the need for complex distributed transaction coordination.
The Core Idea
An idempotent operation is one that produces the same result no matter how many times you execute it. Instead of using distributed transactions to guarantee exactly-once execution, you design your operations so that executing them multiple times (due to retries, network issues, or failures) is harmless.
Think of it like a light switch labeled "ON." Pressing it once turns the light on. Pressing it again does nothing—it's already on. The result is the same whether you press once or a hundred times.
Why This Matters
When network calls fail in distributed systems, you often don't know if the operation completed. Did the server process your request and then the response got lost? Or did it never run? With non-idempotent operations, retrying risks double-processing (charging a credit card twice, for example). With idempotent operations, you can safely retry without worry.
Designing for Idempotency
Instead of: "Add $100 to account" (non-idempotent—retry adds another $100)
Design: "Set balance to $1100 with operation ID abc123" (idempotent—server checks if abc123 was already processed)
The server remembers completed operation IDs. When a retry arrives with the same ID, it returns the cached result without re-executing.
Trade-offs
You're trading distributed transaction complexity for application logic complexity. You need to generate unique operation IDs, store them, and handle lookups. But you gain massive simplicity: no blocking coordinators, no two-phase commit, and natural resilience to network failures and retries.
Key Takeaway: Idempotent operations let you safely retry requests without distributed coordination, turning a complex distributed transaction problem into a simpler application-level pattern.