Multi-step Processes
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
Related Topics
Expand your knowledge by learning about adjacent concepts in system design.
Consistent Hashing Basic
Deconstruct routing rings, virtual nodes, and distribution keys.
Networking Essentials
Learn the important parts of networking that you'll need to know for your system design interviews
API Design
Learn about API design for system design interviews
Cheat Sheet Utility
View and print a concise system design reference card.