Change Data Capture (CDC) Pipelines with Debezium & Kafka Connect
Stream database changes into Kafka with Debezium connectors and Kafka Connect.
In plain words
Slot/binlog, filters, snapshot, and schema history. Next, debezium tasks and Kafka producer. Finally, ordered sink, lag, slot retention, and failures.
Think of it like…
Debezium is the clerk copying a database journal, while Kafka Connect is the managed conveyor and offset cabinet that resumes from the last signed page.
Where you’ve seen it
connector.class=io.debezium.connector.postgresql.PostgresConnector, plugin.name=pgoutput, slot.name=orders_cdc, table.include.list=public.orders; connect offset.storage.topic and lag metrics determine safe recovery.
Words you’ll hear
- Debezium
- Open-source CDC connectors that decode database transaction logs into standardized change event envelopes.
- Kafka Connect
- A scalable framework for source/sink connectors, tasks, configuration, offset, status, and secret plugins.
- CDC
- Change event transport from row-level database history rather than a sequence of application business events.
- Operational boundary
- A failed connector can leave a PostgreSQL replication slot retaining WAL, a connector restart from no saved offsets can repeat the snapshot, and DDL or big transactions produce large tombstone/after-image payloads. Secure and monitor the source slot/binlog and Connect offset topics, size heartbeat and snapshot mode, filter tables/columns to reduce PII, preserve durable offsets before advancing source, and idempotent-apply keyed changes.
Visual diagram
Theory & deep dive
Debezium: the working mechanism
Debezium's Kafka Connect source connector reads a database's transaction log, emits ordered source events with offsets and schema, and stores connector snapshots/configuration/status in Kafka Connect topics.
Slot/binlog, filters, snapshot, and schema history. Debezium tasks and Kafka producer, then durable source and partition checkpoints; this exposes the state governed by CDC.
connector.class=io.debezium.connector.postgresql.PostgresConnector, plugin.name=pgoutput, slot.name=orders_cdc, table.include.list=public.orders; connect offset.storage.topic and lag metrics determine safe recovery.
Change Data Capture Pipelines with Debezium & Kafka Connect: failure mode and production response
A failed connector can leave a PostgreSQL replication slot retaining WAL, a connector restart from no saved offsets can repeat the snapshot, and DDL or big transactions produce large tombstone/after-image payloads.
Secure and monitor the source slot/binlog and Connect offset topics, size heartbeat and snapshot mode, filter tables/columns to reduce PII, preserve durable offsets before advancing source, and idempotent-apply keyed changes. Track Slot/binlog lag as "source retained and consumer-committed position", and make Offset commit age visible to the dataset owner.
How it works, step by step
Step 1 of 41. Configure source
Slot/binlog, filters, snapshot, and schema history. Debezium's Kafka Connect source connector reads a database's transaction log, emits ordered source events with offsets and schema, and stores connector snapshots/configuration/status in Kafka Connect topics.
- Slot/binlog lag
- source retained and consumer-committed position
- Kafka Connect
- A scalable framework for source/sink connectors, tasks, configuration, offset, status, and secret plugins.
When to use it & trade-offs
What it is
Debezium's Kafka Connect source connector reads a database's transaction log, emits ordered source events with offsets and schema, and stores connector snapshots/configuration/status in Kafka Connect topics. connector.class=io.debezium.connector.postgresql.PostgresConnector, plugin.name=pgoutput, slot.name=orders_cdc, table.include.list=public.orders; connect offset.storage.topic and lag metrics determine safe recovery.
Why it matters: A failed connector can leave a PostgreSQL replication slot retaining WAL, a connector restart from no saved offsets can repeat the snapshot, and DDL or big transactions produce large tombstone/after-image payloads. Secure and monitor the source slot/binlog and Connect offset topics, size heartbeat and snapshot mode, filter tables/columns to reduce PII, preserve durable offsets before advancing source, and idempotent-apply keyed changes.
When to reach for it
- Stream database changes into Kafka with Debezium connectors and Kafka Connect.
- Choose Debezium because it provides this capability: Open-source CDC connectors that decode database transaction logs into standardized change event envelopes.
- Keep evidence for Slot/binlog lag at "source retained and consumer-committed position" so the last production stage-Apply/monitor - ordered sink, lag, slot retention, and failures-remains testable.
When to avoid or be careful
- A failed connector can leave a PostgreSQL replication slot retaining WAL, a connector restart from no saved offsets can repeat the snapshot, and DDL or big transactions produce large tombstone/after-image payloads.
- Do not conflate Kafka Connect with Debezium. The second concept contributes different behavior: A scalable framework for source/sink connectors, tasks, configuration, offset, status, and secret plugins.
- Release only after this guardrail is in place: Secure and monitor the source slot/binlog and Connect offset topics, size heartbeat and snapshot mode, filter tables/columns to reduce PII, preserve durable offsets before advancing source, and idempotent-apply keyed changes.
Debezium / Kafka Connect / CDC - roles, limits, and operating cost
Strengths: Open-source CDC connectors that decode database transaction logs into standardized change event envelopes. Debezium's Kafka Connect source connector reads a database's transaction log, emits ordered source events with offsets and schema, and stores connector snapshots/configuration/status in Kafka Connect topics.
Watch out: A failed connector can leave a PostgreSQL replication slot retaining WAL, a connector restart from no saved offsets can repeat the snapshot, and DDL or big transactions produce large tombstone/after-image payloads.
Strengths: A scalable framework for source/sink connectors, tasks, configuration, offset, status, and secret plugins. In this workflow it supports: Capture offsets - durable source and partition checkpoints.
Watch out: The operating cost is real: oldest checkpoint recoverable after restart.
Strengths: Change event transport from row-level database history rather than a sequence of application business events. Its output can be checked with Snapshot duration.
Watch out: Operating guardrail: Secure and monitor the source slot/binlog and Connect offset topics, size heartbeat and snapshot mode, filter tables/columns to reduce PII, preserve durable offsets before advancing source, and idempotent-apply keyed changes.
Interview signals & numbers to know
When this topic comes up
- “Where is the failure boundary for Debezium, and how would Slot/binlog lag reveal it?”
- “Why is Kafka Connect distinct from this behavior: change event transport from row-level database history rather than a sequence of application business events?”
- Production clue: A failed connector can leave a PostgreSQL replication slot retaining WAL, a connector restart from no saved offsets can repeat the snapshot, and DDL or big transactions produce large tombstone/after-image payloads.
- Design probe: Secure and monitor the source slot/binlog and Connect offset topics, size heartbeat and snapshot mode, filter tables/columns to reduce PII, preserve durable offsets before advancing source, and idempotent-apply keyed changes.
Benchmarks & rules of thumb
- Slot/binlog lag
- source retained and consumer-committed position
- Offset commit age
- oldest checkpoint recoverable after restart
- Snapshot duration
- initial table sync overlaps carefully with live transaction position
Common mistakes & follow-ups
Common interview mistakes
- A failed connector can leave a PostgreSQL replication slot retaining WAL, a connector restart from no saved offsets can repeat the snapshot, and DDL or big transactions produce large tombstone/after-image payloads.
- Reporting success from a job exit code without checking Slot/binlog lag and Offset commit age.
- Treating this example as complete without replay, rollback, or access boundaries:
connector.class=io.debezium.connector.postgresql.PostgresConnector,plugin.name=pgoutput,slot.name=orders_cdc,table.include.list=public.orders; connectoffset.storage.topicand lag metrics determine safe recovery.
Likely interviewer follow-ups
- How would you prove this contract instead of only checking that the command ran: Open-source CDC connectors that decode database transaction logs into standardized change event envelopes.
- What does the recovery plan do when this occurs? A failed connector can leave a PostgreSQL replication slot retaining WAL, a connector restart from no saved offsets can repeat the snapshot, and DDL or big transactions produce large tombstone/after-image payloads.
- When is Debezium insufficient for Offset commit age, and what does adding Kafka Connect cost in Slot/binlog lag?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Change Data Capture (CDC) Pipelines with Debezium & Kafka Connect with data engineer interview Q&A and hands-on practice.