Grokking Microservices for System Design Interviews
0% completed
The Dual-Write Problem and the Outbox
1. The Bug Hiding in the Obvious Code
Checkout finishes an order. The code does the two things every event-driven design needs:
db.transaction {
insert order // 1. write to my database
}
broker.publish(orderPlacedEvent) // 2. tell the world
This code is wrong. The bug has a name interviewers expect you to know: the dual-write problem.
Steps 1 and 2 write to two different systems. One is our database. The other is a broker, the piece of infrastructure that carries events to other services. No single transaction covers both.
.....
.....
.....
Like the course? Get enrolled and start learning!