What is Change Data Capture (CDC) in MySQL?

Why Interviewers Ask This

This is a differentiating question used for senior and lead roles. Interviewers want to see if you can explain not just what happens, but why — and what the trade-offs are in different approaches.

Answer

Change Data Capture (CDC) is a technique for tracking and capturing data changes (inserts, updates, deletes) in a database as they happen, and streaming those changes to other systems in real-time. In MySQL, CDC is typically implemented by reading the binary log (binlog), which records all data modifications. Popular CDC tools for MySQL: (1) Debezium: open-source, streams binlog events to Apache Kafka as structured change events; supports MySQL, PostgreSQL, MongoDB. The Kafka topic gets an event for every row change with before/after values; (2) AWS DMS (Database Migration Service): managed CDC for cloud migrations and ongoing replication; (3) Maxwell's Daemon: MySQL binlog to Kafka/Kinesis/stdout; (4) Tungsten Replicator. Requirements: MySQL binlog must be enabled, format set to ROW, and the CDC tool given REPLICATION SLAVE and REPLICATION CLIENT privileges. Use cases: (1) Syncing data to Elasticsearch for search; (2) Updating Redis cache when DB changes; (3) Building event-driven microservices that react to data changes; (4) Audit logs; (5) Real-time analytics pipelines; (6) Zero-downtime database migrations. CDC is more reliable than polling (SELECT WHERE updated_at > last_check) because soft deletes and timing gaps can miss changes.

Pro Tip

Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a MySQL / SQL codebase.