Multi-tier order flows
Checkout across inventory, payment, and fulfillment without dual-write lies.
Multi-tier order flows
Business constraint
Place order: reserve inventory, charge payment, enqueue fulfillment. Partial failure must not strand money or stock.
Naive v0
Distributed transactions across three systems. Or best-effort sequential calls with no saga/compensation.
Failure drill
Charged but not reserved. Reserved but not charged. Double charge on retry. Fulfillment ships twice.
Evolution path
Iteration 1
Order aggregate as source of truth + outbox events. Workers drive steps idempotently.
Iteration 2
Reservations with leases/TTL; payment with idempotency keys; fulfillment claimed once.
Iteration 3
Compensation paths documented and tested (release reserve, refund).
Implementation cut
State machine in the order service. Every external effect keyed. Chaos-test mid-step crashes.
Numbers
Duplicate charge rate ≈ 0. Orphan reservation rate under TTL. End-to-end success after retry.
Pattern tags
Self-check
- Why avoid multi-system 2PC here?
- What does the outbox guarantee?
- How do reservation leases help?
- What must be idempotent?
- What compensations do you need?
Walkthrough
Recordings will appear here when published. Until then, work the failure drill and lab locally — pause after each iteration and write the metric that moved.