Intermediate TrackBack
Intermediate
🚀
Change Data Capture (CDC)
Capturing changes efficiently from source systems.
Section 1 of 3: What is CDC?0%
What is CDC?
Study Material
Change Data Capture (CDC) is a technique for identifying and capturing changes made to data in a database, then delivering those changes in real-time or near-real-time to downstream systems.
Why CDC Matters:
Traditional approaches have significant drawbacks:
Polling/Querying (Traditional):
- Query source every X minutes: WHERE updated_at > last_run
- Misses deletes (no row to query!)
- High load on source database
- Not truly real-time
- Requires updated_at column on every table
CDC (Modern):
- Reads database transaction log
- Captures ALL changes (insert, update, delete)
- Minimal source impact
- Near real-time (seconds)
- Works without schema modifications
How CDC Works:
Databases maintain a transaction log (also called WAL, redo log, binlog) for recovery purposes. CDC tools read this log to capture changes.
Database Transaction Logs:
- PostgreSQL: Write-Ahead Log (WAL)
- MySQL: Binary Log (binlog)
- SQL Server: Transaction Log
- Oracle: Redo Log
CDC Capture Flow:
- 1Application writes to database
- 2Database records change in transaction log
- 3CDC tool reads transaction log
- 4CDC tool publishes change event
- 5Consumers process change event
Types of Changes Captured:
- INSERT: New row added
- UPDATE: Existing row modified (before + after values)
- DELETE: Row removed
Popular CDC Tools:
| Tool | Databases | Output |
|---|---|---|
| Debezium | PostgreSQL, MySQL, MongoDB, Oracle | Kafka |
| AWS DMS | Most major databases | S3, Kinesis, RDS |
| Fivetran | 150+ connectors | Cloud DWH |
| Airbyte | 300+ connectors | Various destinations |
| Oracle GoldenGate | Oracle, others | Various |