One order, three services, no step left half-done.
dine is an ordering system for a restaurant. Each order needs a table held, the kitchen told and money collected, in three separate services. If one step fails, the steps already done undo themselves. The tickets below are orders running on the system.
Waiting for the first order…
{{ mineState === 'ok' ? T('Bạn chưa có đơn nào.') : T('Bạn chưa có đơn nào trong {n} đơn gần nhất.', { n: orders.length }) }} Press “Book a table” to book one.
✓ done ✕ failed ↺ undo … waiting
Showing simulated data. Connection lost, reconnecting… Live from the system.
Order {{ focusOrder.customer }} {{ focusState }}
See order details →You are looking at an order on the system. Log in to book a table yourself, watch your own order run through 3 services, and try cancelling it.
Log in to bookYou have no orders yet. Book a table to watch your own order run through 3 services, and try cancelling it.
{{ autoNote }} Click any ticket to see another order.
- Booked by
- {{ focusWho }}
- Guests
- {{ T('{n} người', { n: focusOrder.size }) }}
- Booking time
- {{ hhmm(focusOrder.start_at) }}
- Leaving
- {{ hhmm(focusOrder.end_at) }}
- Sent
- {{ clock(focusOrder.created_at) }}
- {{ it.qty }}× {{ it.name }} {{ money(it.qty * it.price) }}
Total{{ money(focusOrder.total) }}
Timeline
- {{ e.at }} {{ e.text }}
Step by step
Click a ticket to see how that order went through each service.
See the scenarios
Each card opens a sample order that takes exactly one branch of the saga, with a diagram of each service's reply. To try it yourself, press Book a table and turn on “Incident test”. Why a saga and not one shared transaction? Read the article.
What happens to an order
Three steps run at once
Holding the table, telling the kitchen and collecting the money don't wait for each other. The booking is confirmed only when all three report done.
One step fails, what was done is undone
If the payment is declined, the held table is released and the dishes sent to the kitchen are cancelled. No order is left half-done.
Late replies are still handled
A slow network can make a service report done after the order was cancelled. The system notices and undoes that step on its own instead of ignoring it.
A sudden crash does not lose orders
The order and the outgoing requests are written in the same transaction. If the sending machine stops halfway, another one picks up the work.
Architecture
Why dine exists, what each service does, and why microservices are more than splitting code into many repos: read the introduction.
One database per service
No service reads another service's data directly. To know something, it asks through messages.
They only talk through Kafka
Order sends commands to one topic and the services reply to another. Nobody calls anybody directly.
Order is the only one that knows the whole order
The other services only take work, do it and report the result. Decisions to cancel or undo all belong to order.
Break an order yourself
Log in with Google to book your own table and pick a failure: a declined card, or a service that replies so late the system thinks it has died. Then watch the system untangle itself.
Log in with Google (coming soon)