Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save liemle3893/cd39d21ecce735d3a6677b9bc3e8eb42 to your computer and use it in GitHub Desktop.

Select an option

Save liemle3893/cd39d21ecce735d3a6677b9bc3e8eb42 to your computer and use it in GitHub Desktop.
THEORY: Distributed Transactions and why you should avoid them (2 Phase Commit , Saga Pattern, TCC, Idempotency etc)

Distributed Transactions and why you should avoid them

  1. Modern technologies won't support it (RabbitMQ, Kafka, etc.);
  2. This is a form of using Inter-Process Communication in a synchronized way and this reduces availability;
  3. All participants of the distributed transaction need to be avaiable for a distributed commit, again: reduces availability.

Implementing business transactions that span multiple services is not straightforward. Distributed transactions are best avoided because of the CAP theorem. Moreover, many modern (NoSQL) databases don’t support them. The best solution is to use the Saga Pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment