🔀 Distributed Data Patterns — interview questions
10 questions. Filter by what the role asks for; open one for the six layers of the answer. The course is where the answers come from.
10 of 10
01A checkout method saves the order row, then calls `kafka.send("orders", new OrderPlaced(...))` right after, inside the same `@Transactional` method. What's wrong with this, and what does the transactional outbox actually fix?Outboxeasy0-2y02Placing an order touches inventory, payment and the order record, each its own service with its own database. A teammate suggests wrapping the three calls in a distributed transaction with XA. What actually happens if you do that, and why is it avoided in a service architecture?Distributed transactionseasy0-2y03An order saga has three steps today (reserve inventory, charge the card, create the order) and product wants to add fraud review and a loyalty-points step, with a possible retry-then-escalate branch on fraud. Would you build this as choreography or orchestration, and why does that change as the saga grows?Sagasmedium3-5y04A saga refunds a payment as its compensation for a failed order. Someone reviewing the code asks why the refund doesn't just "undo" the original charge the way a database ROLLBACK would. What's the actual difference, and why does it matter for how compensations are designed?Sagasmedium3-5y05An order-history page needs the customer's name, a status label, three product thumbnails and a delivery date, joined from four tables and paged. It's slow and N+1-prone off the write model. What's the CQRS fix, and what does it actually cost to keep in sync?CQRSmedium3-5y06Your outbox table's relay is a polling job that runs `SELECT ... FOR UPDATE SKIP LOCKED` every 200ms. Explain exactly why SKIP LOCKED is what makes running several relay instances safe, and then explain what changes — mechanically — if you switch that relay to Debezium reading PostgreSQL's write-ahead log instead.Outboxhard5-8y07A team proposes event sourcing for a product catalogue because "it gives us a free audit log and the ability to replay history." What would you actually push back on, and what does event sourcing cost that a normal row-plus-audit-table approach doesn't?Event sourcinghard5-8y08A four-step saga is: reserve inventory (compensatable), charge the card (compensatable), send a "your order shipped" push notification (no compensation possible), create the order record (compensatable). Where does the notification actually belong in the sequence, and what does "the pivot" mean here?Sagashard5-8y09Your team is choosing between a hand-rolled `saga` table (`id, step, status`) and a workflow engine like Temporal for orchestrating a saga. What does the engine actually persist differently from a status column, and why does that make workflow code written for it have to be deterministic?Sagassenior8+y10An event-sourced aggregate has a snapshot at version 40 and 12 events after it. A reviewer worries the snapshot might be "out of sync" with a full replay from event zero. Is that a real risk, and how would you actually verify it isn't?Event sourcingsenior8+y