AlgoMaster Logo

Two-phase commit protocol

Ensuring Atomicity in Distributed Systems

Ashish

Ashish Pratap Singh

3 min read

1. What is the Two-Phase Commit Protocol?

The Two-Phase Commit (2PC) Protocol is a distributed algorithm used to ensure that a transaction involving multiple, independent systems (or nodes) is executed atomically. That means either all nodes commit the transaction, or none of them do—keeping the system in a consistent state.

Think of 2PC as a coordinated "yes or no" voting process among all the participants in a transaction. If everyone agrees (votes "yes"), the transaction is committed. If even one participant votes "no," the entire transaction is rolled back.

2. Why Do We Need 2PC?

Premium Content

This content is for premium members only.