Distributed_Commit_Protocols
Distributed_Commit_Protocols
• Why Important?
• - Maintains consistency and reliability in
distributed databases.
Distributed One-Phase Commit
• Definition:
• - A single-step protocol where the coordinator
instructs participants to either commit or
abort.
• How it Works:
• - Coordinator communicates directly with
participants to perform or cancel actions.
• - Simple but lacks fault tolerance, leading to
potential inconsistencies.
Distributed Two-Phase Commit
(2PC)
• Definition:
• - A protocol with two phases to ensure all
participants agree on the transaction
outcome.
• Phase 1: Voting
• - Coordinator sends 'prepare' message.
• - Participants respond 'ready' or 'no'.
• - Coordinator waits for responses or timeout.
Comparison: One-Phase vs. Two-
Phase Commit
• One-Phase Commit:
• - Simple and fast.
• - Low fault tolerance.
• Two-Phase Commit:
• - Ensures consistency.
• - Can block during failure.
• - Higher complexity.
Three-Phase Commit Protocol
(3PC)
• Definition:
• - Non-blocking protocol enhancing 2PC with a
third phase to avoid indefinite blocking.
• Phases:
• 1. Can Commit? - Coordinator checks
readiness.
• 2. Pre-Commit - Coordinator sends 'Pre-
Commit' to participants.
Advantages and Disadvantages
• Advantages:
• - 3PC reduces blocking.
• - Ensures consistency and fault tolerance.
• Disadvantages:
• - More complex than 2PC.
• - Higher communication overhead.
Applications
• - Distributed Databases: Ensures consistency
across nodes.
• - Financial Systems: Reliable commit/abort
decisions.
• - Cloud Computing Systems: For critical
operations.
Conclusion
• - Commit protocols ensure reliability and
consistency in distributed systems.
• - One-Phase Commit is simple but less
reliable.
• - Two-Phase Commit ensures consistency but
can block.
• - Three-Phase Commit is non-blocking but
more complex.