Lesson 3 of 10 Data Pipeline Design Patterns

Designing a Change Data Capture Pipeline

This lesson explains the change data capture (CDC) pipeline, which keeps analytical copies of operational data current by capturing inserts, updates and deletes as they happen, rather than repeatedly extracting whole tables.

Learning outcomes

After completing this lesson, you will be able to:

  • Choose between zero-ETL, AWS DMS and Debezium for capture.
  • Apply captured changes with MERGE.
  • Identify the prerequisites and concerns of CDC.

The reference design

Operational database → DMS full load and CDC (or zero-ETL) → S3 or Redshift → MERGE into Iceberg or Redshift tables.

The capture stage can be built three ways. A zero-ETL integration is fully managed replication from Aurora, RDS for MySQL, DynamoDB and some applications into Redshift; when the source and target are supported, it has the least operational overhead because there is nothing to build or run. AWS DMS with CDC reads the source's transaction log and writes changes to S3, Redshift, Kinesis or MSK. It covers other sources and targets, and it is the usual choice when the changes must land in the data lake.

Debezium on MSK Connect uses open-source Kafka Connect connectors to read the log into Kafka topics, which suits organisations that already standardise on Kafka. After capture, the changes are applied to target tables with MERGE, which inserts, updates or deletes each row. The following table summarises the capture options.

OptionHow it worksChoose when
Zero-ETL integrationManaged replication from Aurora, RDS for MySQL, DynamoDB and some applications into RedshiftThe source and target are supported and the least operational overhead is required
AWS DMS with CDCReads the transaction log; writes to S3, Redshift, Kinesis or MSKOther sources or targets, or changes are needed in the lake
Debezium on MSK ConnectKafka Connect source connectors read the log into Kafka topicsThe organisation already standardises on Kafka
Sort into groups

Which CDC capture option?

Exam skills 1.1.2 · 2.1.5

Choose the capture option for each requirement.

Log in to try this activity Interactive activities are free with an account.

Applying changes

Captured changes arrive as a stream of inserts, updates and deletes, each with an operation flag and a timestamp or sequence number. They are applied to the target with MERGE, keeping only the latest change for each key in each batch. Iceberg tables in the lake and Redshift tables both support MERGE.

The following diagram shows a batch of changes being reduced to the latest per key and merged.

Applying a batch of captured changes. The batch holds two updates to order 5, an insert of order 8 and a delete of order 7. Only the latest change for each key is kept, and MERGE applies it: order 5 becomes shipped, order 8 is inserted and order 7 is removed from the target table.
The rows are illustrative; t1 to t4 is the order of the changes.
Put in order

Applying a batch of changes

Exam skills 2.4.2 · 2.1.7

Put the steps for applying a batch of captured changes in order.

Log in to try this activity Interactive activities are free with an account.

Prerequisites and concerns

Change data capture depends on the source database's transaction log, so logging must be enabled in a form the CDC tool can read, such as binary logging in MySQL or logical replication in PostgreSQL. The source must also keep its log long enough to cover any interruption of the pipeline; if the pipeline stops for longer than the log retention, changes are lost and a full reload is needed.

Schema changes on the source, such as a new column, must be handled downstream, either automatically or by an agreed process. And deletes must be applied to the target, not ignored, or the copy gradually drifts from the source and reports include records that no longer exist.

The following diagram compares a nightly export from Aurora to Redshift with a zero-ETL integration.

The orders pipeline before and after. Before, a nightly script exports full tables to CSV, slowing the database, and Redshift is a day behind. After, an Aurora zero-ETL integration replicates changes continuously with no extraction queries, so orders appear in Redshift within minutes.
Zero-ETL integrations need a supported source and target.
Select all that apply

CDC concerns

Exam skills 1.1.11 · 2.4.2

Identify the true statements about running a CDC pipeline.

Log in to try this activity Interactive activities are free with an account.
Worked example

Finding the missing component

Orders from an Aurora MySQL database must appear in Redshift within minutes. Today a nightly script exports full tables to CSV and loads them, and it slows the database during the export.

This is the CDC pattern with its CDC component missing. The fix is an Aurora zero-ETL integration with Redshift, which replicates changes continuously with no extraction queries. If zero-ETL were not available for the source, a DMS task with ongoing replication to Redshift would be the next choice.

Check yourself

Why does change data capture not slow the source application?

Show answer

It reads changes from the database's transaction log rather than querying the tables.

Exam Tips

Remember for the exam

  • CDC: DMS or zero-ETL → MERGE into Iceberg or Redshift.
  • Zero-ETL gives the least operational overhead where it is supported.
  • CDC reads the transaction log, so it does not slow the source application.
  • Apply deletes as well as inserts and updates.