Hard👤 8-15 years 1 min read

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

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.

Coffee Chat Question

Concept Made Simple

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

🧠Mind Map Answer

Remember It Faster

2PCprepare → commit, coordinator, locks held
Problemblocking, coordinator SPOF, poor availability
Insteadsaga + compensations, eventual consistency

🔥What If?

Think Beyond the Expected

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 blockingcoordinator SPOF / held locksavailability costsaga + eventual consistency alternativewhen 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

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

🧩Related Technologies

XAsagaTemporalCAP theorem

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?

Support our platform by exploring our recommended products.

As an Amazon affiliate, purchases through these links may earn us a small commission — at no extra cost to you. It helps keep Full Stack Interview Guru free.

Related Questions