AdvancedAbout 20 min

    Distributed Transactions (Saga vs 2PC)

    Read the full article on Substack

    7 min read.

    Learn how microservices maintain data consistency across multiple databases using Two-Phase Commit and Saga patterns.

    CoordinatorIdlePayment DBIdleInventory DBIdle

    0/4One order must write to two databases, or to neither.

    Check your understanding

    Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.

    2PC or saga?

    Sort

    Sort each trait into the distributed-transaction approach.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    Two-phase commit

    Drop items here

    Saga

    Drop items here
    6 pieces left to place

    Quiz

    21 questions
    Question 1 of 21
    Score: 0

    In the Saga pattern, how do you handle a failure in the final step of a transaction?

    Done with this lesson?

    Sign in free to keep your progress, streak and quiz scores.

    Keep going