Databases · Senior · Question 66 of 75
An order flow spans the orders, payments and shipping services, each with its own database. How do you keep them consistent without distributed transactions?
- 1Two-phase commit across all databases for every order
- ✓Correct answer: A saga: a sequence of local transactions coordinated by events or an orchestrator, with compensating actions when a step fails
- 3Put all three services on the same table
Explanation
Two-phase commit couples services and blocks when the coordinator fails. Sagas accept temporary inconsistency and need idempotent, retryable steps.