AlgoMaster Logo

Two-Phase Commit (2PC)

Medium Priority8 min readUpdated May 26, 2026
AI Mock Interview

Practice this topic in a realistic system design interview

Two-Phase Commit (2PC) is the classic protocol for atomic commit across multiple transactional resources. It answers one narrow question: can several participants agree to commit or abort the same transaction?

The idea is direct. A coordinator asks every participant whether it can commit. If everyone says yes, the coordinator tells them all to commit. If anyone says no or fails to respond, the coordinator tells everyone to abort.

2PC is the foundation that many distributed databases and transaction managers build on. It works best when participants are transactional resources with durable logs, short lock times, and a trusted coordinator. Across slow services, external APIs, and long-running business workflows, it is usually a poor fit, and its weaknesses explain why those workflows often reach for compensation, idempotency, and reconciliation instead.

The Core Idea

Premium Content

This content is for premium members only.