2PC vs sagas
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Layer 3 · Go deeper · 7 min

    Go deeper

    Size it, build it, then make the calls an interviewer will push you on.

    Back of the envelope

    Size it up

    Tap through each step of the arithmetic.

    What does one 2PC commit cost across three databases?

      How many 2PC commits a second can one hot row take?

        How many minutes of failed orders a month with four 99.9% participants?

          Build-up · 6 steps

          Watch the coordinator crash after the votes

          One food order, three participant databases and one coordinator. First the normal prepare and vote, then a crash at the worst moment.

          Step 1 of 6

          The app asks to commit

          The app has written to all three databases under one global transaction ID, and each still holds its row locks. Now it asks the coordinator to commit.

          4 interview moments

          You’re the candidate

          The interviewer pushes on the hard parts. Pick an approach and see how it holds up.

          1. Deep dive 1 of 4

            Interviewer

            “Your orchestrator’s charge call to the payment gateway times out. What does the saga do next?”

            Your move. Pick an approach:

          2. Deep dive 2 of 4

            Interviewer

            “A food order saga: payment, restaurant acceptance, rider assignment, with timeouts and compensations. How do you drive it?”

            Your move. Pick an approach:

          3. Deep dive 3 of 4

            Interviewer

            “A tatkal berth must be held while the user pays. How do you coordinate the seat and the payment?”

            Your move. Pick an approach:

          4. Deep dive 4 of 4

            Interviewer

            “A transfer moves credit between accounts on different CockroachDB ranges. Do you build a saga?”

            Your move. Pick an approach: