Services

Resources

Company

/

Change data capture

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

Pipeline diagram of change data capture. An orders database writes to its WAL, Debezium reads the WAL, and change events flow out in order. One event is enlarged: order 42, before: pending, after: paid. The events fan out to a warehouse, a search index and a cache, kept in sync within seconds. Below the WAL, a disk bar is mostly red: when a consumer stalls, unread WAL fills the disk.

Putting this into practice?

Talk to One2N about our backend engineering services

Talk to One2N about our backend engineering services