dual write
Writing the same change to two separate systems, such as a database and a message broker, from application code with no shared transaction.
In more detail
One write can succeed while the other fails: the record is saved but no event is sent, or an event is sent for a change that was rolled back. The two systems then disagree, sometimes called split brain. The transactional outbox pattern removes the second write from the request path.
Related terms
- transactional outbox — Saving an event into an outbox table in the same database transaction as the business change, then having a separate worker publish it.
- broker — A server that receives messages from producers, stores them and delivers them to consumers, such as RabbitMQ or Apache Kafka.
- transaction — A group of database changes that succeed or fail together, so the data is never left half-updated.
- change data capture — Reading every insert, update and delete from a database's own change log and turning them into a stream of events.
- phantom event — An event published to Kafka for a change that never made it into the database.
- ACID — The four guarantees of a database transaction: atomicity, consistency, isolation and durability.
- resharding — Changing how data is split across shards, such as adding shards, while the system keeps running.
- live migration — Moving data or traffic to a new home while the system keeps serving requests.
Taught in
- Asynchronous Event Processing: Outbox Pattern & Queues — Production Full-Stack Engineering
- Full-Stack System Verification: Capstone Integration — Production Full-Stack Engineering
- Dual Writes And Why They Lose Data — Apache Kafka & Event Streaming
- Partitioning, Sharding And Hot Keys — Scalable System Design & Distributed Architecture