Change Data Capture (CDC)
Change Data Capture (CDC) captures changed rows from a database's transaction log and delivers them to consumers with low latency. This technique enables Spice to keep locally accelerated datasets up-to-date in real time with the source data. It is efficient because it only transfers the changed rows instead of re-fetching the entire dataset.
Benefits​
Using locally accelerated datasets configured with CDC enables Spice to provide high-performance accelerated queries and efficient real-time updates.
Example Use Case​
Consider a fraud detection application that needs to determine whether a pending transaction is likely fraudulent. The application queries a Spice-accelerated, real-time updated table of recent transactions to check if a pending transaction resembles known fraudulent ones. With CDC, the table is kept up-to-date, allowing the application to quickly identify potential fraud.
Considerations​
When configuring datasets to be accelerated with CDC, ensure that the data connector supports CDC and can return a stream of row-level changes. See the Supported Data Connectors section for more information.
The startup time for CDC-accelerated datasets may be longer than for non-CDC-accelerated datasets due to the initial synchronization.
It is recommended to use CDC-accelerated datasets with persistent data accelerator configurations (i.e., file
mode for DuckDB
/SQLite
or PostgreSQL
). This ensures that when Spice restarts, it can resume from the last known state of the dataset instead of re-fetching the entire dataset.
Supported Data Connectors​
Enabling CDC by setting refresh_mode: changes
in the acceleration settings requires support from the data connector to provide a stream of row-level changes.
Currently, the only supported data connector is Debezium.
Example​
See an example of configuring a dataset to use CDC with Debezium by following the recipe at Streaming changes in real-time with Debezium CDC.
version: v1beta1
kind: Spicepod
name: cdc-debezium
datasets:
- from: debezium:cdc.public.customer_addresses
name: cdc
params:
debezium_transport: kafka
debezium_message_format: json
kafka_bootstrap_servers: localhost:19092
kafka_security_protocol: PLAINTEXT
acceleration:
enabled: true
engine: sqlite
mode: file
refresh_mode: changes