Distributed transactions for system design interviews, explained
Design almost any real system across microservices — place an order, transfer money, book a trip — and you hit the same wall: the operation touches two or more databases, and you need them to change together or not at all, but there is no single transaction that spans them. Inside one database you get that for free: one ACID transaction, commit or roll back the whole thing. The moment the data lives in separate services, that guarantee is gone, and you have to rebuild atomicity across services by hand — on a network that can fail halfway through. Distributed transactions are how you do it, and the interview is almost never "name one." It is "here are five ways, ordered from strongest consistency to most scalable — which do you actually pick here, and why?" This guide is the map that ties the options together: the problem, the full spectrum of distributed transaction patterns, the consistency tradeoff running through all of them, and a decision guide for choosing.
The reason it comes up is that distributed data is the default in any system big enough to be worth designing. Split a monolith into services with their own databases — or just shard one database — and every operation that used to be one transaction now spans a network. You cannot wrap it in a lock and walk away: a write can commit in one service and the follow-up fail in another, leaving the system in a state no single rollback can fix. So the real skill is not memorising one pattern; it is knowing the whole landscape — strong-but-blocking at one end, scalable-but-eventually-consistent at the other — and picking the right point on it for the system in front of you. That judgment, named out loud, is what the round is testing.
Why distributed transactions come up in system design interviews
Distributed transactions rarely get their own prompt. They surface inside a design — an order system, a payments flow, a booking engine — the moment the interviewer asks how a multi-step write stays consistent when each step lands in a different service. You say "I'll make it transactional," and the follow-up is the trap: across separate databases there is no transaction to make it with, so what do you actually do when step two commits and step three fails? It is a favourite probe because the easy half — "it should be atomic" — is table stakes, and the real signal is whether you can lay out the options, weigh strong versus eventual consistency, and commit to one with a reason.
The interviewer rarely lets "wrap it in a transaction" stand. "You need to update two services atomically — reserve inventory in one, charge the card in another. There's no shared database and no shared transaction. Walk me through your options from strongest consistency to most scalable, and tell me which you'd actually pick here and why." That question — not a technique but the spectrum and a defended choice — is the one a single memorised pattern can never cover.
The rounds on Zynter are modelled on how the loop runs, not scraped from any candidate's recall. What matters for prep is the shape: you name an option, and the next sentence pushes on its cost — the blocking in two-phase commit, the lost isolation in a saga, the lag in an eventually-consistent design — and asks why you still chose it.
What the interviewer is really testing
A distributed-transactions answer is read on the same four dimensions as any design decision. Problem solving — do you see the dual-write problem and reach for the right point on the spectrum, or just say "transaction"? Communication — can you line up 2PC, saga, outbox and avoidance in one breath and say what each trades? Technical execution — do you handle partial failure, idempotency, and the strong-versus-eventual consistency call concretely? Time management — did you spend your words on the tradeoff and the choice, not on naming a library? Reading this guide teaches the landscape; it does not teach you to defend a choice while someone asks "and if the coordinator dies right there?"
The problem: one transaction across services, and the dual-write trap
Start with why this is hard, because every pattern below is an answer to one problem. In a single database, a multi-step change is one ACID transaction: everything commits together or everything rolls back, and isolation hides the half-done state in between. Spread that change across two services with separate databases, and the guarantee evaporates — there is no shared transaction, and no database can roll back a commit that happened in another.
The sharpest version of this is the dual-write problem: you need to do two things atomically — say, write a row to your database and publish an event (or call another service) so the rest of the system learns about it. There is no transaction around both. So any of these can happen:
- The DB write commits, then the event publish fails — your data changed but nobody downstream knows. The order exists; the warehouse never hears about it.
- The event publishes, then the DB write fails or rolls back — the system reacts to something that didn't really happen. The warehouse ships; your order table has no record.
- The process crashes between the two — and you cannot tell which of the above you are in.
The sentence that scores: the moment one logical operation spans two stores, there's no single transaction to guarantee both — so a naive "write the DB, then publish the event" can diverge whenever the second step fails or the process dies between them. Every distributed-transaction pattern is a way to close that gap. Naming the dual-write problem by name, unprompted, is the tell that you have actually hit this in practice.
The spectrum of solutions: 2PC, saga, outbox, event-driven, and avoidance
There is no single fix — there is a spectrum, and laying it out from strongest consistency to most scalable is the answer the interviewer wants. Each option buys atomicity a different way and pays a different price:
- Two-phase commit (2PC). A coordinator asks every participant to prepare (do the work, hold locks), and only if all agree does it tell them to commit. It gives real, synchronous atomicity — the strong-consistency end of the spectrum — but it is blocking (locks held across the whole prepare-and-wait window), the coordinator is a single point of failure, and many services (third-party APIs) simply do not support a prepare/commit protocol, so it doesn't scale for microservices. Reach for it only with few participants on the same infrastructure. (This is a protocol worth its own deep dive — see the two-phase commit walkthrough on the Zynter blog.)
- Saga. Instead of one atomic transaction, run a sequence of local transactions, each committing in its own service, and define a compensating transaction for each step to semantically undo it if a later one fails (refund the charge, release the stock). It scales — no global locks — but you give up isolation: intermediate committed state is visible to others mid-saga. Best for multi-step business flows across services. (The saga pattern, choreography vs orchestration and the no-isolation problem get their own deep dive on the Zynter blog.)
- Transactional outbox + CDC. This directly kills the dual-write problem: in one local transaction, write your business row and an "event" row into an outbox table in the same database — so both commit atomically. A separate relay (polling, or change-data-capture reading the DB log) then reliably publishes those outbox rows to the broker. You get an atomic DB write plus guaranteed-eventually event publish, at the cost of eventual delivery and at-least-once semantics (consumers must be idempotent). The default reliable-messaging answer.
- Event sourcing / event-driven. Make the event the source of truth: instead of storing current state and separately publishing a notification, you append events to a log and derive state from them, so there is no second write to diverge. It fits naturally with sagas and outboxes and leans fully into eventual consistency and asynchronous propagation.
- Avoid the distributed transaction entirely. The strongest move is often to redesign so the operation doesn't span services: pull the data that must change together into one service / one database so it goes back to being a single local ACID transaction. Re-drawing service boundaries around what must be atomic beats any distributed protocol — "the best distributed transaction is the one you don't have."
The sentence that scores: there's a spectrum — 2PC for synchronous strong atomicity but it blocks and doesn't scale; saga for scalable multi-step flows but you lose isolation; the outbox to publish events reliably without the dual-write; event-driven to make the event the source of truth; and, best of all, redesigning boundaries so the transaction stays inside one service. The whole axis is strong consistency at one end, scalability and eventual consistency at the other.
System Design
HLD · Core concept
Lay out the distributed-transaction spectrum out loud
A decision guide: which pattern to pick
Knowing the options is half the answer; the signal is choosing, with a reason tied to the system. Walk the decision in order, strongest consistency first, and stop at the first one that fits:
- Can you redesign to avoid it? If the data that must change together can live in one service / one database, do that — it is a single local ACID transaction and beats every distributed protocol. Always consider this first.
- Do you need strict, synchronous atomicity with few participants on the same infrastructure? Then 2PC is defensible — strong consistency, bounded blast radius — but only because the blocking and coordinator-SPOF cost is small at that scale. Never reach for it across many services or external APIs.
- Is it a multi-step business flow across services (order, payment, booking) where some lag is acceptable? Use a saga — local transactions plus compensations — and be ready to name the lost isolation and the idempotency it demands.
- Do you just need to update your DB and reliably tell others? Use the transactional outbox (optionally with CDC) to make the write and the event atomic, and accept eventual delivery.
- Is the whole system already event-driven? Lean into event sourcing and asynchronous propagation, with sagas for the multi-step flows.
The sentence that scores: I'd first try to redesign so the transaction stays in one service; if it genuinely must span services, I'd pick 2PC only for a couple of participants on shared infra, a saga for a multi-step business flow where I can tolerate the lost isolation, and the outbox when I just need to publish events reliably. The choice is really a consistency-versus-scalability call for this operation. Committing to one, and saying why the others lose here, is the judgment the round rewards.
System Design
HLD · Core concept
Pick one pattern and defend the tradeoff out loud
The tradeoff running through all of it: strong vs eventual consistency
Every option on the spectrum is really a position on one axis — how much consistency you demand versus how much scale and availability you want — and naming that axis explicitly is what turns a list of patterns into an argument:
- Strong consistency (2PC end). Everyone sees the committed result at once; no window where the data disagrees. You pay for it with blocking — held locks, a coordinator that can stall or fail the whole operation, and throughput that falls as participants grow. It does not scale, which is exactly why it sits at one end.
- Eventual consistency (saga / outbox / event-driven end). Each step commits locally and the rest of the system catches up asynchronously, so there is a window where different services disagree — an order marked paid before the warehouse has heard. In return you get scale, availability, and no global locks. The cost is complexity you must handle: idempotency (at-least-once delivery means every step and consumer must tolerate duplicates), partial-failure handling (compensations, retries, dead-letter queues), and designing the system to be correct despite the intermediate disagreement.
- The real question is never "which is better" but "how much inconsistency, for how long, can this operation tolerate?" Money movement wants strong guarantees; a like count or a recommendation can be eventually consistent for seconds. Tie the pattern to the business requirement and you have given the interviewer the reasoning, not just the name.
The point to state plainly: distributed transactions trade consistency for scalability, and the whole spectrum is just where you set that dial. Say which the operation needs and why, and the pattern choice follows.
How to talk about distributed transactions in an interview
The probes from every section rhyme. Master these five and you can defend a choice in any design, not just this checklist.
- "These two writes have to be atomic but they're in different services — what do you do?" → Name the dual-write problem, then walk the spectrum from redesign-to-avoid through 2PC, saga and outbox, and pick the point that fits. (problem solving)
- "Why not just use two-phase commit everywhere?" → It blocks on held locks, the coordinator is a single point of failure, and external APIs don't support prepare/commit — strong but doesn't scale; fine only for a few participants on shared infra. (technical execution)
- "Walk me from strongest consistency to most scalable." → 2PC (synchronous, blocking) → saga (local txns + compensations, no isolation) → outbox/event-driven (reliable async, eventual) → and, best, redesign so it stays in one service. (communication)
- "A step commits and the next one fails — now what?" → There's no global rollback; a saga runs compensations in reverse, an outbox guarantees the event eventually, and everything must be idempotent for at-least-once delivery. (technical execution)
- "Strong or eventual consistency here?" → Tie it to the operation: money movement wants strong guarantees and can pay the blocking cost; a status update tolerates a short window, so go eventual and handle duplicates and partial failure. (problem solving)
Each maps to a debrief dimension. Reading them teaches the answers; it does not teach you to deliver them while someone asks "and if the coordinator dies right there?" — that only comes from saying them out loud.
How to prepare: a short plan
You do not need a new topic for every design. You need the distributed-transactions map automatic, so when a design needs a multi-service write you reach for the right point on the spectrum without stalling.
- Day 1: Internalise the problem — the dual-write trap and why one ACID transaction can't span services — until you can draw the three ways a naive write-then-publish diverges from memory.
- Day 2: Drill the spectrum and the decision guide: 2PC, saga, outbox + CDC, event-driven, and avoidance, and exactly what each trades on the strong-versus-eventual axis. This is where the follow-ups live.
- Day 3: Place the choice inside a real design (an order checkout, a money transfer, a booking): identify the spanning transaction, pick a point on the spectrum, and defend it against the one you rejected. Then do it out loud, timed, with someone pushing on partial failure.
This explainer sits alongside the deeper pattern walkthroughs — the two-phase commit and saga deep dives — so once the map is automatic, drop into whichever pattern the design actually needs.
Frequently asked questions
What is a distributed transaction?
A distributed transaction is a single logical operation that has to change data in more than one place — multiple services, multiple databases, or multiple partitions — atomically, so that either every part succeeds or none does. Inside one database you get this for free from an ACID transaction: commit or roll back the whole thing. Across separate systems there is no shared transaction and no shared lock, so you have to rebuild that all-or-nothing guarantee yourself, on a network where any step can fail or the process can crash between steps. Because a naive sequence of writes can leave the systems disagreeing, a family of patterns — two-phase commit, sagas, the transactional outbox, event-driven designs — exists specifically to coordinate the change and recover from partial failure.
How do you handle distributed transactions in system design?
There is no single answer — there is a spectrum, and the strong candidate picks a point on it for the operation in front of them. First, try to avoid the distributed transaction altogether by redesigning so the data that must change together lives in one service and one database, making it a plain local transaction. If it genuinely must span services, choose by requirement: two-phase commit for strict, synchronous atomicity with a few participants on shared infrastructure (accepting that it blocks and doesn't scale); a saga — a sequence of local transactions with compensating transactions to undo on failure — for a multi-step business flow where you can tolerate lost isolation; and the transactional outbox when you mainly need to update your database and reliably publish an event. The decision is really a strong-versus-eventual consistency call.
What is the dual-write problem?
The dual-write problem is the core reason distributed transactions are hard. It arises whenever one operation has to write to two systems that don't share a transaction — classically, writing a row to your own database and then publishing an event (or calling another service) so the rest of the system learns about it. Because there is no transaction around both writes, they can diverge: the database commit can succeed while the event publish fails, the event can publish while the database write rolls back, or the process can crash between the two, leaving you unable to tell which happened. The transactional outbox pattern solves it by writing the business row and the event into the same database in one local transaction, then relaying the event from that outbox table separately and reliably.
What is the difference between two-phase commit and a saga?
They sit at opposite ends of the consistency-versus-scalability spectrum. Two-phase commit is synchronous and strongly consistent: a coordinator makes every participant prepare and hold locks, then commit together, so there is no window where the data disagrees — but it blocks on those held locks, the coordinator is a single point of failure, and external services often can't participate, so it doesn't scale beyond a few participants on shared infrastructure. A saga gives up that strict atomicity and isolation: it runs a sequence of local transactions that each commit immediately, and on a failure it runs compensating transactions in reverse to semantically undo the completed steps. The saga scales across services and external APIs and is eventually consistent, at the cost of visible intermediate state and mandatory idempotency.
How do I practise a system design interview out loud?
Reading about distributed transactions is not the same as defending a choice while an interviewer pushes on partial failure. On Zynter, the HLD track runs live voice rounds modelled on how real system design loops run — you talk through a design (like an order checkout or a money transfer) on a shared canvas, and a voice interviewer follows up one question at a time ("these two writes must be atomic — now what?", "why not 2PC?", "walk me from strongest consistency to most scalable"), then gives you a debrief on problem solving, communication, technical execution and time management. The score is a practice signal, not a hiring decision.
Practise it on Zynter
You can name every pattern. The round is won on the tradeoff and the choice you defend.
Pick an HLD system design round with a multi-service write, lay the spectrum out on the canvas, and defend your pick out loud to a voice interviewer that keeps asking "why not two-phase commit?" and "a step committed, the next failed — leave it consistent." — then read the debrief. Zynter.ai is on-demand mock interviews modelled on real company loops, with 150+ rounds across 20 companies including the HLD system design track (Sep 2026).
Practise an HLD system design round →
Browse all interview tracks




Top comments (0)