CDC Data Streaming: How Change Data Capture Works
CDC data streaming uses change data capture to read every insert, update, and delete from a database as it is committed and publish each one as an event to a streaming platform such as Apache Kafka. Downstream systems receive changes within seconds, without batch jobs and without changing the application that owns the data.
Most of the data a company wants to act on in real time already lives in operational databases: orders, payments, customer records, stock levels. CDC is how that data gets into a streaming architecture. This guide explains how change data capture works, compares the three capture methods, walks through a reference pipeline, and covers the parts that teams most often get wrong in production.
What is CDC in data streaming?
Change data capture is a technique that detects changes to data in a source system and delivers them to other systems. In data streaming, those changes become a continuous, ordered stream of events. Instead of asking “what does the customer table look like now?”, consumers receive “customer 4711 changed their address at 10:42” the moment it happens.
That shift from snapshots to events is what makes CDC useful. A warehouse can stay in sync without nightly reloads, a cache can invalidate the exact entry that changed, and a fraud service can react to a new transaction before the customer leaves the checkout. Each consumer reads the same stream at its own pace, so adding a new use case does not mean adding another extract job against the production database.
CDC vs. batch ETL and scheduled ELT
Batch ETL copies data on a schedule, often once a night, and transforms it on the way into the warehouse. Scheduled ELT tools shorten the interval to minutes, but they still query the source repeatedly and copy whatever has changed since the last run. Both approaches leave a gap between what happened and what downstream systems know, and both put repeated query load on the source.
CDC removes the schedule. Changes flow as they are committed, in the order they were committed, and the source database does not need to answer extra queries. CDC handles the extract step; transformation and loading still happen downstream, which is why CDC is usually the first stage of a streaming ETL pipeline rather than a replacement for it.
How change data capture works
Every relational database keeps a transaction log so it can recover after a crash and replicate to standby servers. PostgreSQL calls it the write-ahead log (WAL), MySQL calls it the binary log (binlog), Oracle uses redo logs, and SQL Server has its own transaction log with a built-in CDC feature on top. Every committed change is written there first, in commit order.
Log-based CDC tools read this log the way a replica would. They decode each entry into a structured change event and publish it to a topic. Because the log already exists for the database’s own purposes, reading it adds very little load, and nothing in the application or the schema has to change.
Anatomy of a change event
A CDC change event carries more than the new row. Debezium, the most widely used open-source CDC project, produces events with a consistent structure across databases:
- An operation type: create, update, delete, or read (for snapshot rows)
- The row’s state before the change, where the database provides it
- The row’s state after the change
- Source metadata such as the database, table, log position, and transaction ID
- A timestamp for when the change was processed
The before and after states are what make CDC events more useful than a copied row. A consumer can see that an order moved from “pending” to “shipped”, not only that it is now “shipped”, and a delete arrives as an explicit event instead of a row that silently disappears.
CDC methods compared
There are three ways to capture changes from a database. They differ in latency, completeness, and the load they put on the source.
Log-based CDC
Log-based CDC reads the transaction log directly. It captures every change, including deletes and intermediate states, in exact commit order, and it can resume from its last log position after a restart without losing events. It is the standard choice for data streaming. The trade-off is setup: the database must be configured to expose its log, for example with logical replication in PostgreSQL or row-based binlog in MySQL, and the CDC tool needs the right permissions.
Query-based CDC
Query-based CDC, also called polling, runs a query on a schedule to find rows whose last-updated timestamp is newer than the previous run. It works with any database and needs no special configuration, but every table needs a reliable update timestamp column. It cannot see deletes, and if a row changes twice between polls, only the latest state is captured. Every poll also adds query load to the source.
Trigger-based CDC
Trigger-based CDC adds database triggers that write each change into a shadow table, which a separate process then reads. It captures deletes and works on databases without accessible logs. The cost is that every write to a tracked table now does extra work inside the same transaction, which slows the application and adds triggers that someone has to maintain.
| Method | Latency | Captures deletes | Load on source | Old values available | Typical use |
|---|---|---|---|---|---|
| Log-based | Seconds or less | Yes | Very low | Yes, where the database logs them | Data streaming, replication, event-driven systems |
| Query-based | Polling interval (minutes) | No | Medium, grows with polling frequency | No | Simple incremental loads where deletes do not matter |
| Trigger-based | Near real time | Yes | High on write-heavy tables | Yes | Legacy databases with no accessible log |
Streaming data with CDC: The reference architecture
A CDC streaming pipeline has five parts. The source database writes changes to its transaction log. A CDC connector, typically Debezium running on Kafka Connect, reads the log and turns each change into an event. Apache Kafka stores those events in topics, usually one topic per table, so they are durable and can be replayed. An optional stream processing layer, such as Apache Flink or streaming SQL, filters, masks, joins, or aggregates the changes in flight. Sink connectors then deliver the results to warehouses, lakehouses, search indexes, caches, or applications.
Kafka is what turns CDC from point-to-point replication into a platform. Each table’s changes are captured once and then shared by every team that needs them, and a new consumer can start from the beginning of a topic to build its own view of the data. For the full design of the pipeline around CDC, see our guide to building streaming data pipelines.
Teams that do not want to run connectors themselves have managed options. Confluent offers fully managed log-based CDC source connectors for PostgreSQL, MySQL, SQL Server, and Oracle, which take a snapshot of existing data at startup and then stream every row-level change. Google Datastream is a serverless CDC service that replicates databases into BigQuery and Cloud Storage, and AWS Database Migration Service supports ongoing replication with CDC. A detailed comparison of these and other tools is in our guide to streaming ETL tools.
Getting the hard parts right
Capturing the first change events is quick. Running CDC reliably for years takes attention to four areas.
Initial and incremental snapshots
The transaction log only holds recent history, so a new pipeline must first copy the data that already exists. CDC tools do this with an initial snapshot that reads each table and emits a “read” event per row before switching to the log. On large tables, a traditional snapshot can take hours and blocks new changes from flowing until it finishes.
Debezium added incremental snapshots in version 1.6. They read tables in chunks while log streaming continues, use watermarks to resolve conflicts between snapshot rows and live changes, and can be triggered again at runtime, for example when a new table is added to the pipeline. For large production databases, incremental snapshots are usually the safer default.
Schema changes and Schema Registry
Source schemas change: columns are added, renamed, or retyped. If change events carry no schema contract, a new column can break every consumer downstream. Log-based CDC tools track the source schema over time, and pairing them with a schema registry such as Confluent Schema Registry lets each event reference a versioned Avro, Protobuf, or JSON Schema. Compatibility rules then decide whether a change is allowed before it reaches consumers, which turns schema drift from a production incident into a deployment check. Our article on stream governance covers this in more depth.
Ordering, delivery guarantees, and duplicates
CDC tools use the row’s primary key as the Kafka message key, so all changes to the same row land in the same partition and stay in order. Ordering across different rows or tables is not guaranteed, and consumers should not assume it. In most setups, delivery is at least once: after a connector restart, a few events can be sent again. Consumers should therefore be idempotent, for example by writing to the target with upserts keyed on the primary key, so a duplicate event leaves the data unchanged.
Watch log retention as well. If a connector is down longer than the database keeps its log, the missing changes are gone and the table needs a new snapshot. In PostgreSQL the opposite risk applies: a replication slot holds WAL until the connector reads it, so a stalled connector can fill the database server’s disk. Both cases call for monitoring connector lag and alerting on it.
The transactional outbox pattern
CDC exposes table changes, but table rows are not always the right events to share. Publishing raw tables couples every consumer to the source schema, and a service that writes to its database and then sends a message to Kafka separately can fail between the two steps, leaving them out of sync.
The outbox pattern solves both problems. The service writes its business data and an event row into an outbox table in the same database transaction, so both succeed or neither does. CDC then streams the outbox table, and Debezium’s outbox event router sends each event to the right topic. Consumers receive deliberate, well-defined business events such as “OrderPlaced”, while the service keeps its internal schema private.
CDC data streaming use cases
The same pattern supports a wide range of projects. These are the ones we see most often:
- Keeping a warehouse or lakehouse in sync with operational databases in near real time, as in data streaming in Snowflake
- Migrating databases to the cloud with minimal downtime, by streaming changes to the new system until cutover
- Offloading reads from legacy and mainframe systems, a common pattern in financial services
- Sharing data between microservices without direct database access, using the outbox pattern
- Invalidating caches and updating search indexes the moment a record changes
- Building audit trails that record who changed what, and when, using the transaction metadata in each event
- Giving AI agents real-time data so they act on the current state of the business, not yesterday’s export
FAQs
What is CDC in data streaming?
CDC in data streaming is the practice of capturing every insert, update, and delete from a database as it is committed and publishing each change as an event to a streaming platform such as Apache Kafka. Downstream systems then receive changes within seconds instead of waiting for a batch job.
Is CDC the same as ETL?
No. CDC covers the extract step: it detects changes and delivers them. ETL also transforms and loads the data. In a streaming architecture, CDC usually feeds a stream processor or sink connectors that handle the transform and load steps, so CDC and streaming ETL work together.
Does CDC slow down the source database?
Log-based CDC adds very little load, because it reads the transaction log the database already writes. Query-based CDC adds load with every poll, and trigger-based CDC adds work to every write. The main operational risk with log-based CDC is log retention, so monitor connector lag.
Do you need Kafka for CDC?
Not strictly. Debezium Server can send changes to other messaging systems, and managed services such as Google Datastream replicate directly into a target. Kafka becomes valuable once several systems need the same changes, because each change is captured once, stored durably, and can be replayed by any consumer.
What is the most reliable CDC data streaming platform?
Reliability depends more on the method and the operating model than on the brand. Log-based CDC on a durable platform such as Kafka is the most reliable pattern, whether you run open-source Debezium yourself or use managed connectors from a provider such as Confluent. Choose based on your source databases, your team’s capacity to operate the platform, and your recovery requirements.
How Mimacom can help
Mimacom designs and runs CDC pipelines that stream data out of operational, legacy, and core systems without changing the applications that own it. As an IBM partner delivering Confluent, our Confluent consulting team builds on Confluent’s managed CDC connectors or open-source Debezium and Kafka, depending on where your data lives and how much of the platform you want to operate yourself. We start with one use case, set up snapshots, schema governance, and monitoring properly from the beginning, and leave you with a platform that the next use case can build on.
CDC turns your databases into event streams
Change data capture is the most direct way to bring existing operational data into a streaming architecture. Log-based CDC captures every change in order with almost no load on the source, Kafka makes those changes available to every team that needs them, and patterns such as incremental snapshots and the outbox keep the pipeline dependable as it grows. Start with the tables that matter most to one real-time use case, and build from there.