
Two-Phase Commit
Two-Phase Commit (2PC) is a protocol used in distributed computing to ensure that a group of databases or systems agree on a transaction's outcome. It consists of two main phases: 1. **Prepare Phase**: A coordinator asks all participants if they are ready to commit the transaction. If all participants agree, they move to the next phase. 2. **Commit Phase**: The coordinator then instructs all participants to either commit or roll back the transaction based on their responses. This process ensures data consistency across multiple systems, preventing partial updates that could cause errors.