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 140/ 160
07. Streaming & Real-Time Data Engineering

End-to-End Real-Time CDC → Kafka → Flink → Iceberg Pipeline

Assemble a production-shaped CDC path from databases through Kafka and Flink into Iceberg tables.

AdvancedCDC · Flink · Iceberg3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

Snapshot plus exact binlog/LSN handoff. Next, keyed Kafka event versions and contracts. Finally, Iceberg transaction, offset alignment, audit and replay.

Think of it like…

CDC writes the bank ledger, Kafka is a numbered armored tube, Flink is a checkpointed processing room, and Iceberg publishes a complete new inventory edition rather than exposing half-filled boxes.

Where you’ve seen it

Debezium emits (lsn,txid,table,pk,before,after) to a keyed topic; Flink emits to Iceberg keyed by pk, commits table files on checkpoint, and resumes Kafka offsets/state together when the checkpoint/catalog transaction is recoverable.

Words you’ll hear

CDC
A database-to-log event feed that captures source mutations with transaction order and source identity.
Flink
A stateful processor that transforms CDC streams and coordinates checkpoints with compatible sink commits.
Iceberg
A snapshot-based table target whose data/delete files are atomically referenced for analytical consumers.
Operational boundary
A bootstrap gap loses changes, Debezium restart can retain slots, Kafka EOS does not span Iceberg, and a Flink checkpoint after an external table commit can cause duplicate MERGEs unless the sink transaction key is aligned. Coordinate a low-watermark snapshot/CDC handoff, monitor connector slot and Kafka lag, use Flink Iceberg's two-phase commits, dedupe stable source primary keys/version, pin catalog compatibility, and rehearse checkpoint rollback plus late schema events.

Visual diagram

Loading interactive diagram

Theory & deep dive

CDC: the working mechanism

An end-to-end CDC path snapshots a source, streams committed log changes through Kafka, enriches/windows them in Flink, and commits idempotent row changes into an Iceberg snapshot with checkpoints and replay controls.

Snapshot plus exact binlog/LSN handoff. Keyed Kafka event versions and contracts, then Flink event-time/enrichment with checkpoints; this exposes the state governed by Iceberg.

End-to-End Real-Time CDC → Kafka → Flink → Iceberg Pipeline in one concrete design

Debezium emits (lsn,txid,table,pk,before,after) to a keyed topic; Flink emits to Iceberg keyed by pk, commits table files on checkpoint, and resumes Kafka offsets/state together when the checkpoint/catalog transaction is recoverable.

Key takeaway: An end-to-end CDC path snapshots a source, streams committed log changes through Kafka, enriches/windows them in Flink, and commits idempotent row changes into an Iceberg snapshot with checkpoints and replay controls

End-to-End Real-Time CDC → Kafka → Flink → Iceberg Pipeline: failure mode and production response

A bootstrap gap loses changes, Debezium restart can retain slots, Kafka EOS does not span Iceberg, and a Flink checkpoint after an external table commit can cause duplicate MERGEs unless the sink transaction key is aligned.

Coordinate a low-watermark snapshot/CDC handoff, monitor connector slot and Kafka lag, use Flink Iceberg's two-phase commits, dedupe stable source primary keys/version, pin catalog compatibility, and rehearse checkpoint rollback plus late schema events. Track End-to-end lag as "source commit or LSN time to Iceberg snapshot", and make Source slot retention visible to the dataset owner.

Key takeaway: Coordinate a low-watermark snapshot/CDC handoff, monitor connector slot and Kafka lag, use Flink Iceberg's two-phase commits, dedupe stable source primary keys/version, pin catalog compatibility, and rehearse checkpoint rollback plus late schema events.

How it works, step by step

Step 1 of 4
CDC

1. Bootstrap CDC

Snapshot plus exact binlog/LSN handoff. An end-to-end CDC path snapshots a source, streams committed log changes through Kafka, enriches/windows them in Flink, and commits idempotent row changes into an Iceberg snapshot with checkpoints and replay controls.

snapshot plus exact binlog/LSN handoff
Key numbers at this step
End-to-end lag
source commit or LSN time to Iceberg snapshot
Flink
A stateful processor that transforms CDC streams and coordinates checkpoints with compatible sink commits.

When to use it & trade-offs

What it is

An end-to-end CDC path snapshots a source, streams committed log changes through Kafka, enriches/windows them in Flink, and commits idempotent row changes into an Iceberg snapshot with checkpoints and replay controls. Debezium emits (lsn,txid,table,pk,before,after) to a keyed topic; Flink emits to Iceberg keyed by pk, commits table files on checkpoint, and resumes Kafka offsets/state together when the checkpoint/catalog transaction is recoverable.

Why it matters: A bootstrap gap loses changes, Debezium restart can retain slots, Kafka EOS does not span Iceberg, and a Flink checkpoint after an external table commit can cause duplicate MERGEs unless the sink transaction key is aligned. Coordinate a low-watermark snapshot/CDC handoff, monitor connector slot and Kafka lag, use Flink Iceberg's two-phase commits, dedupe stable source primary keys/version, pin catalog compatibility, and rehearse checkpoint rollback plus late schema events.

When to reach for it

  • Assemble a production-shaped CDC path from databases through Kafka and Flink into Iceberg tables.
  • Choose CDC because it provides this capability: A database-to-log event feed that captures source mutations with transaction order and source identity.
  • Keep evidence for End-to-end lag at "source commit or LSN time to Iceberg snapshot" so the last production stage-Commit table - Iceberg transaction, offset alignment, audit and replay-remains testable.

When to avoid or be careful

  • A bootstrap gap loses changes, Debezium restart can retain slots, Kafka EOS does not span Iceberg, and a Flink checkpoint after an external table commit can cause duplicate MERGEs unless the sink transaction key is aligned.
  • Do not conflate Flink with CDC. The second concept contributes different behavior: A stateful processor that transforms CDC streams and coordinates checkpoints with compatible sink commits.
  • Release only after this guardrail is in place: Coordinate a low-watermark snapshot/CDC handoff, monitor connector slot and Kafka lag, use Flink Iceberg's two-phase commits, dedupe stable source primary keys/version, pin catalog compatibility, and rehearse checkpoint rollback plus late schema events.

CDC / Flink / Iceberg - roles, limits, and operating cost

CDC
Best for: A database-to-log event feed that captures source mutations with transaction order and source identity.

Strengths: A database-to-log event feed that captures source mutations with transaction order and source identity. An end-to-end CDC path snapshots a source, streams committed log changes through Kafka, enriches/windows them in Flink, and commits idempotent row changes into an Iceberg snapshot with checkpoints and replay controls.

Watch out: A bootstrap gap loses changes, Debezium restart can retain slots, Kafka EOS does not span Iceberg, and a Flink checkpoint after an external table commit can cause duplicate MERGEs unless the sink transaction key is aligned.

Flink
Best for: A stateful processor that transforms CDC streams and coordinates checkpoints with compatible sink commits.

Strengths: A stateful processor that transforms CDC streams and coordinates checkpoints with compatible sink commits. In this workflow it supports: Process state - Flink event-time/enrichment with checkpoints.

Watch out: The operating cost is real: WAL/binlog ahead of durable connector offset.

Iceberg
Best for: A snapshot-based table target whose data/delete files are atomically referenced for analytical consumers.

Strengths: A snapshot-based table target whose data/delete files are atomically referenced for analytical consumers. Its output can be checked with Checkpoint/table snapshot.

Watch out: Operating guardrail: Coordinate a low-watermark snapshot/CDC handoff, monitor connector slot and Kafka lag, use Flink Iceberg's two-phase commits, dedupe stable source primary keys/version, pin catalog compatibility, and rehearse checkpoint rollback plus late schema events.

Interview signals & numbers to know

When this topic comes up

  • “Where is the failure boundary for CDC, and how would End-to-end lag reveal it?”
  • “Why is Flink distinct from this behavior: a snapshot-based table target whose data/delete files are atomically referenced for analytical consumers?”
  • Production clue: A bootstrap gap loses changes, Debezium restart can retain slots, Kafka EOS does not span Iceberg, and a Flink checkpoint after an external table commit can cause duplicate MERGEs unless the sink transaction key is aligned.
  • Design probe: Coordinate a low-watermark snapshot/CDC handoff, monitor connector slot and Kafka lag, use Flink Iceberg's two-phase commits, dedupe stable source primary keys/version, pin catalog compatibility, and rehearse checkpoint rollback plus late schema events.

Benchmarks & rules of thumb

End-to-end lag -
source commit or LSN time to Iceberg snapshot
Source slot retention -
WAL/binlog ahead of durable connector offset
Checkpoint/table snapshot -
offset state and Iceberg commit recover to one aligned version

Common mistakes & follow-ups

Common interview mistakes

  • A bootstrap gap loses changes, Debezium restart can retain slots, Kafka EOS does not span Iceberg, and a Flink checkpoint after an external table commit can cause duplicate MERGEs unless the sink transaction key is aligned.
  • Reporting success from a job exit code without checking End-to-end lag and Source slot retention.
  • Treating this example as complete without replay, rollback, or access boundaries: Debezium emits (lsn,txid,table,pk,before,after) to a keyed topic; Flink emits to Iceberg keyed by pk, commits table files on checkpoint, and resumes Kafka offsets/state together when the checkpoint/catalog transaction is recoverable.

Likely interviewer follow-ups

  • How would you prove this contract instead of only checking that the command ran: A database-to-log event feed that captures source mutations with transaction order and source identity.
  • What does the recovery plan do when this occurs? A bootstrap gap loses changes, Debezium restart can retain slots, Kafka EOS does not span Iceberg, and a Flink checkpoint after an external table commit can cause duplicate MERGEs unless the sink transaction key is aligned.
  • When is CDC insufficient for Source slot retention, and what does adding Flink cost in End-to-end lag?
Interview tip: Lead with the data path and failure boundary: An end-to-end CDC path snapshots a source, streams committed log changes through Kafka, enriches/windows them in Flink, and commits idempotent row changes into an Iceberg snapshot with checkpoints and replay controls. Then make the answer operational: Coordinate a low-watermark snapshot/CDC handoff, monitor connector slot and Kafka lag, use Flink Iceberg's two-phase commits, dedupe stable source primary keys/version, pin catalog compatibility, and rehearse checkpoint rollback plus late schema events.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply End-to-End Real-Time CDC → Kafka → Flink → Iceberg Pipeline with data engineer interview Q&A and hands-on practice.

Open Data Engineer Q&A →Machine Learning Q&A
Previous topic
Monitoring Kafka & Streaming Pipelines (Consumer Lag, Throughput, JMX Metrics)
Next topic
Data Quality Dimensions (Accuracy, Completeness, Consistency, Timeliness, Validity)