An online shop has split its monolith into separate payment, inventory and shipping services, each with its own database. Placing an order now means charging the card through an external payment provider, reserving stock and booking a courier, and there is no shared transaction across them. The shop handles 3 million orders a day, with peaks of 2,000 orders per second during sales. If any step fails, the earlier steps must be undone: a refund issued, stock released, a booking cancelled. Customers must never be charged for an order that will not ship, and support staff need to see exactly where any order is stuck.
Functional requirements
Accept an order and return an order ID immediately
Run payment, stock reservation and courier booking as ordered steps
Run compensating actions (refund, release stock, cancel booking) when a step fails
Show the current state and full history of any order to customers and support
Park orders that keep failing for manual review
Non-functional requirements
Order placement responds in under 300 ms at p95; fulfilment finishes asynchronously
Every order reaches a final state (completed or compensated); none are left half done
Each step is idempotent, so retries never charge twice or reserve stock twice
A crashed coordinator resumes in-flight orders without losing their progress
Constraints and scale
3 million orders per day, peaking at 2,000 orders per second
Payment provider p99 latency of 2 seconds and occasional multi-minute outages
Three downstream services, each owning its own database
You will practise
Replace a distributed transaction with a saga of local transactions and compensations
Compare orchestration with choreography for multi-step workflows
Make steps idempotent and persist saga state so retries and crashes are safe
Show 3 hints
Where is the record of which steps have already succeeded for an order?
How does the payment service recognise a retried charge request it has already processed?
Use the outbox pattern so a state change and its event are written together.