HardExperience level: 8-15 years1 min read

Why is two-phase commit (2PC) avoided in microservices, and what's used instead?

Reviewed by Gurusankar M.

Asked inAmazonMicrosoftbankingGoogle
#2pc#distributed transaction#saga#xa#availability
Report issue

Short Answer

2PC gives ACID across services but needs a coordinator and synchronous locks held across the prepare/commit phases — so it blocks on any slow/failed participant (coordinator is a SPOF) and kills availability and scalability. Microservices instead use sagas (compensating transactions) and eventual consistency.

On this page

Concept Made Simple

Coffee Chat Question

“Why is two-phase commit (2PC) avoided in microservices, and what's used instead?”

Remember It Faster

Mind Map Answer

2PC
prepare → commit, coordinator, locks held
Problem
blocking, coordinator SPOF, poor availability
Instead
saga + compensations, eventual consistency

Think Beyond the Expected

What If?

When might 2PC still be acceptable?

Within a tightly-coupled, low-latency boundary (e.g. a single DB with XA across two resources, or a small set of co-located services) where strong consistency is mandatory and the participants are reliable. Across many independent, internet-scale services it's avoided for availability reasons.

Real World

The CAP/availability trade-off pushes microservices toward sagas; 2PC survives mostly in classic enterprise/XA contexts (single-org, reliable resources), not in elastic distributed systems.

Interviewer's Expectation

Keywords they're listening for:

  • 2PC = ACID but blocking
  • coordinator SPOF / held locks
  • availability cost
  • saga + eventual consistency alternative
  • when 2PC is OK

Common Mistakes

  • Reaching for 2PC across many services
  • Assuming distributed ACID is free
  • Ignoring coordinator failure modes

Best Practices

  • Prefer sagas + eventual consistency at scale
  • Reserve 2PC/XA for reliable, bounded scopes
  • Design idempotent compensations

Follow-up Questions

  1. How does a saga relate to the CAP theorem choice?
  2. What is the 2PC 'in-doubt' / blocking problem?
  3. Where does XA still make sense?

Continue Learning with AI

Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly — AI is your learning companion, not a shortcut.

Plain-language foundations

I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner.

Topic: Data Consistency (Microservices)
Interview question: "Why is two-phase commit (2PC) avoided in microservices, and what's used instead?"

Please:
1. Explain the core idea in simple, plain language, using an everyday analogy.
2. Define any technical terms you use.
3. Walk through one small, concrete example.
4. Finish with a single sentence I can easily remember.

Keep the tone friendly and assume I'm new to this topic.
Open inChatGPTGeminiClaude

Was this answer helpful?

Affiliate links

Equipment for a comfortable, productive setup.

As an Amazon Associate I earn from qualifying purchases.