Distributed Systems · Data across services
Distributed transactions and two-phase commit
Once data lives in two databases, no single commit covers both. Two-phase commit makes everyone prepare, then obey one coordinator's decision: correct, but slow, lock-heavy and stuck if that coordinator dies.
- Time22 min
- LevelSenior
- Experiments1 live
- Check6 questions







Work each service writes its rows inside an open transaction and keeps its locks.
Prepared each saves its changes to disk and votes YES or NO.
Decision all YES: the coordinator logs COMMIT. Any NO or silence: abort.
COMMIT participants commit, release their locks and acknowledge.