← All concepts
Data & storage
Change data capture
Stream every database change as an event so other systems stay in sync without dual writes.
Writing to a database and then separately to a search index or cache can leave them inconsistent if one write fails. CDC tails the database's own change log and publishes each insert, update and delete, so downstream copies follow the source of truth.
See it in action
Step through the scenarios on the diagram.
Laying out diagram…
1/6The app updates a price in the database — and nothing else. No risky dual writes.
- App
- — Writes only to the database
- Database
- — Write-ahead log records every change
- CDC connector
- — Tails the log
- Change events
- — One per row change
- Search index
- — Stays in sync
- Cache invalidator
- — Evicts stale keys
- Warehouse
- — Analytics copy
How it works
- Tools read the write-ahead log or binlog and publish to an event stream.
- Consumers update search indexes, caches and warehouses.
Trade-offs
- Downstream copies are eventually consistent.
- Schema changes must be coordinated with consumers.