advanced
CDC
Capture data changes for downstream systems with ordering, replay, schema evolution, idempotency, and privacy controls.
Change Data Capture (CDC) streams row-level inserts, updates, and deletes from the OLTP log (WAL, binlog, oplog) to downstream consumers: search indexes, warehouses, caches, event buses. Tools include Debezium, Maxwell, native logical replication, and managed connectors.
Ordering and schema evolution matter: consumers must handle out-of-order retries idempotently; additive schema changes are safer than destructive ones; tombstones signal deletes to Kafka compacted topics.
OLTP → WAL → CDC connector → queue → search / warehouse / cache projector
On interviews: contrast CDC with nightly batch ETL for freshness; explain idempotent projection into Elasticsearch; mention PII filtering before the stream leaves trust boundary.
Common pitfalls: full table scan disguised as sync; no delete propagation; consumer lag unbounded; breaking rename without compatibility layer; exposing raw CDC topic without ACL.
The trade-off is near-real-time downstream freshness versus pipeline complexity, ordering guarantees, and operational monitoring of lag and poison messages.
Checklist:
- Define CDC source: WAL/binlog/oplog.
- Guarantee idempotent downstream apply.
- Plan schema evolution and delete events.
- Monitor lag and dead-letter handling.
- Filter PII at capture or consume boundary.