Interview's MateData Engineer
Interview's Mate

Data Engineer

SQL · Spark · Lakehouse · Streaming

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Data Engineer topics
Lesson 128/ 160
07. Streaming & Real-Time Data Engineering

Change Data Capture (CDC) Pipelines with Debezium & Kafka Connect

Stream database changes into Kafka with Debezium connectors and Kafka Connect.

AdvancedDebezium · Kafka Connect · CDC3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

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

Loading interactive 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.

Change Data Capture Pipelines with Debezium & Kafka Connect in one concrete design

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.

Key takeaway: 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

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.

Key takeaway: 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.

How it works, step by step

Step 1 of 4
Debezium

1. 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, filters, snapshot, and schema history
Key numbers at this step
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

Debezium
Best for: Open-source CDC connectors that decode database transaction logs into standardized change event envelopes.

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.

Kafka Connect
Best for: A scalable framework for source/sink connectors, tasks, configuration, offset, status, and secret plugins.

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.

CDC
Best for: Change event transport from row-level database history rather than a sequence of application business events.

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; connect offset.storage.topic and 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?
Interview tip: Lead with the data path and failure boundary: 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. Then make the answer operational: 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.

Knowledge check

Loading quiz

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.

Open Data Engineer Q&A →Machine Learning Q&A
Previous topic
Schema Registry & Data Contracts (Avro, Protobuf, JSON Schema Compatibility)
Next topic
Real-Time Stream Processing with Apache Flink