Concepts · Concept

Change Data Capture

“CDC is a technique for detecting and streaming row-level changes (inserts, updates, deletes) from a database as they happen, by reading the database’s own transaction log — not by polling or by adding extra application code. Tools like Debezium tail Postgres’s write-ahead log (WAL) or MySQL’s binlog, and publish each change as an event, typically onto Kafka, for downstream consumers to react to.”

Why it exists — the problem it solves:

When you have a source-of-truth database and one or more downstream systems that need to stay in sync with it (a search index, a cache, a replica in another region, an analytics pipeline), you have two options:

  1. Dual writes — your application code writes to the database, then also writes to the downstream system directly.
  2. CDC — your application only writes to the database; a separate process tails the log and propagates changes.

One-line takeaway: “CDC keeps two systems in sync by reading the source of truth’s own change log, rather than trusting application code to reliably write to both — safer than dual writes, at the cost of a small eventual-consistency lag.”