.NET Architecture & System Design Interview Question #93

What is a distributed transaction?

Transactions, CQRS, Event Sourcing & Distributed Consistency Mid-Level Intermediate

Quick Interview Answer

A distributed transaction coordinates an atomic operation across multiple transactional resources or services. Traditional approaches such as two-phase commit attempt to make all participants commit or abort together.

Detailed Explanation

A distributed transaction coordinates an atomic operation across multiple transactional resources or services. Traditional approaches such as two-phase commit attempt to make all participants commit or abort together.

Distributed transactions can reduce availability and increase coupling and operational complexity. Modern distributed architectures often prefer local transactions plus messaging, idempotency, and compensating workflows when strict cross-service atomicity is not essential.

Code Example

Coordinator
   |------ Resource A
   |------ Resource B

Prepare all
then Commit all
or Abort all