Back to explorer
Core Fundamentals 5 Min

Multi-step Processes

MEDIUM

Multi-Step Processes (Distributed Transactions)

Distributed microservices must coordinate multi-step workflows while maintaining data consistency without performance bottlenecks.


1. Consistency Protocols

  • Two-Phase Commit (2PC):

A central coordinator asks participants to prepare, then commits. It is a strong consistency protocol, but it is blocking and reduces availability.

  • Saga Pattern:

A series of local transactions. Each step updates its database. If a step fails, the system executes compensatory transactions to roll back changes.

  • Choreography: Services communicate via event streams (Kafka) without a central coordinator.
  • Orchestration: A central orchestrator service coordinates execution steps.

2. Transactional Outbox Pattern

Avoids dual-write failures (e.g., writing to database succeeds, but publishing to Kafka fails). The application writes the event payload directly to an outbox database table within the same ACID transaction, and a background parser (Debezium) polls the outbox and publishes events.


3. References & Tech Blogs