Databases & Transactions interview question · Most asked

How do you keep data consistent across services without distributed transactions?

Summary

Use the saga pattern: a sequence of local transactions where each step publishes an event or command, and failures trigger compensating actions (refund, release inventory). Combine with the transactional outbox to publish events reliably and idempotent consumers.

Longer Answer

Two-phase commit (2PC) across services is rarely used because it couples availability and blocks on coordinator failures. Sagas can be choreographed (events) or orchestrated (a coordinator such as Temporal or Step Functions).

Key Points

  • Sagas with compensations
  • Outbox for reliable events
  • Idempotent consumers
  • Avoid 2PC across services

More most-asked Databases & Transactions questions

← All Databases & Transactions questions