Posts

Showing posts with the label 3PC Protocol

Understanding the Three-Phase Commit (3PC) Protocol in Distributed Systems

In modern software engineering, distributed database systems and microservices need a way to ensure data consistency across multiple servers. If a user makes a transaction, it must either succeed everywhere or fail everywhere. This is where commit protocols come into play. While the Two-Phase Commit (2PC) protocol is widely known, it suffers from a major flaw: blocking . If the coordinator node crashes, the participating nodes can get stuck indefinitely waiting for instructions. To solve this, the Three-Phase Commit (3PC) Protocol introduces an extra step to remove this blocking vulnerability. Here is how it works . The Three Phases of 3PC The protocol is divided into three distinct steps managed by a central "Coordinator" communicating with multiple "Cohorts" (participants). 1. Phase One: CanCommit (Voting Phase) The Coordinator sends a CanCommit query to all cohorts asking if they are ready to process a transaction. If a cohort is ready, it replies with a Yes ...