Transactions in Distributed Systems

Topics covered
Popular Clips
Episode Highlights
Saga Pattern
The distributed saga pattern is essential for managing transactions across multiple data stores in microservices. explains that each microservice must handle its own database, making it challenging to ensure that transactions are completed successfully across different systems 1. adds that this pattern requires a sequence of local transactions, unlike traditional applications that rely on a single database 2. This complexity arises because each service must know where to listen for work and where to publish results, maintaining a loosely coupled system 3.
When you've got microservices that's spread out, you've got two different databases. And so when we had a single database that was asset compliant, it kind of had this basic pattern as a two phase commit where it basically ensures that things happen in the right order and they either happen fully or they don't.
---
The saga pattern is a solution to this problem, allowing for distributed transactions without relying on a two-phase commit.
  Â
Orchestrator Logic
Orchestrating service logic in microservices centralizes transaction management, providing a "brain" to coordinate actions. describes how an orchestrator mediates between services, making it easier to trace and manage complex workflows 4. However, notes that this approach introduces tight coupling, as the orchestrator must be aware of all services involved 5. Despite this, the orchestrator simplifies the process by modeling the entire transaction flow, making it easier to understand and manage 6.
The orchestrator has a brain and so it centralizes that logic. That's really the big difference. The choreography was all distributed logic.
---
This centralized approach contrasts with choreography, where each service independently manages its transactions.
  Â
Saga Completion
The saga completion process involves the client initiating a transaction and receiving updates until completion. explains that the client must be informed when the saga completes, often through polling or webhooks 7. This process is more complex than traditional applications, as each service must communicate its status through message brokers 8. highlights that while choreography allows for loosely coupled services, it requires careful management of message queues and event handling 9.
The service sends back a response when the order id is created and submits an event via webhook or similar when the actual saga completes.
---
This ensures that all parts of the transaction are completed successfully, even if some services fail.
Related Episodes


Clean Architecture - Are Microservices Truly Decoupled?
Answers 383 questionsUnderstanding Serial Transactions for Databases like Redis
Answers 383 questionsDesigning Data-Intensive Applications – Multi-Object Transactions
Answers 383 questions

Are Microservices … for real?
Answers 383 questions

Designing Data-Intensive Applications – Lost Updates and Write Skew
Answers 383 questions

Gitlab vs Github, AI vs Microservices
Answers 383 questions

Designing Data-Intensive Applications – Multi-Leader Replication
Answers 383 questionsDesigning Data-Intensive Applications – Scalability
Answers 383 questionsDesigning Data-Intensive Applications – Leaderless Replication
Answers 383 questionsThe DevOps Handbook – The Technical Practices of Feedback
Answers 383 questions

Clean Code - How to Write Classes the Right Way
Answers 383 questions

Things to Know when Considering Multi-Tenant or Multi-Threaded Applications
Answers 383 questions

Designing Data-Intensive Applications - SSTables and LSM-Trees
Answers 383 questions

Data Structures - Arrays and Array-ish
Answers 383 questions

The DevOps Handbook - The Technical Practices of Flow
Answers 383 questions
