Get Started Free
Wade Waldron

Wade Waldron

Staff Software Practice Lead

The Dual Write Problem

Overview

The dual write problem occurs when your service needs to write to two external systems in an atomic fashion. A common example would be writing state to a database and publishing an event to Apache Kafka. The separate systems prevent you from using a transaction, and as a result, if one write fails it can leave the other in an inconsistent state. This is an easy trap to fall into.

There are valid options for avoiding the dual write problem, such as a transactional outbox, event sourcing, and change data capture. However, we have to be careful to avoid solutions that seem valid on the surface but just move the problem.

Topics:

  • Emitting Events
  • The Dual Write Problem
  • Invalid Solution: Emit the Event First
  • Invalid Solution: Use a Transaction
  • Change Data Capture (CDC)
  • The Transactional Outbox Pattern
  • Event Sourcing
  • The Listen to Yourself Pattern

Resources

Use the promo code MICRO101 to get $25 of free Confluent Cloud usage

Be the first to get updates and new content

We will only share developer content and updates, including notifications when new content is added. We will never send you sales emails. 🙂 By subscribing, you understand we will process your personal information in accordance with our Privacy Statement.