Services

Resources

Company

CDC (change data capture)

Change data capture (CDC) is a pattern for turning every insert, update and delete in a database into an ordered stream of change events. Log-based CDC reads the database's own transaction log instead of polling tables. Downstream systems such as warehouses, search indexes and caches can then stay in sync within seconds.

How it works

A connector such as Debezium attaches to the database log. In PostgreSQL it reads the write-ahead log (WAL) through a logical replication slot. In MySQL it reads the binary log. Each event carries the row before and after the change, plus its log position, so a restarted connector resumes from the last committed offset. For example, UPDATE orders SET status = 'paid' WHERE id = 42 becomes one event with before.status = 'pending' and after.status = 'paid'.

Why it matters in production

CDC keeps a replication slot or log position open on your primary or replica. If the consumer stalls, the database keeps the log it has not yet read, and disk usage grows until someone notices. Teams need alerts on slot lag and retained log size, not only on the connector's health check.

See also

On the One2N blog

References

  1. Debezium documentation

  2. PostgreSQL logical decoding

Comic about change data capture: reports, search and cache all show stale copies of the orders database; the database keeps a change diary of creates, updates and deletes, and CDC reads it instead of querying tables; each change, like order 42 going from pending to paid, becomes an event that updates every copy within seconds; if the reader stops, unread diary pages fill the disk, so the team alerts on reader lag.