SimuVedaSystem Design Lab Open in the lab

Data platform / Intermediate / 5 min / Updated

Change data capture: syncing search with the database

Dual writes drift on crashes, polling is late and misses deletes, and CDC from the write-ahead log (Debezium) keeps the search index in sync.

Start the simulation → Change the load, break a part, watch what happens. Free, no sign-up.

In short

What is change data capture?

Change data capture streams every insert, update and delete from the database log to other systems.

Why does it matter?

Search indexes, caches and warehouses must follow the main database without the app writing to all of them.

What is the trade-off?

CDC adds a pipeline (Debezium, Kafka) to run; polling is simpler but late and blind to deletes; dual writes drift.

How do you explain it in an interview?

"Postgres logical replication into Debezium, a Kafka topic per table, a consumer upserting and deleting in Elasticsearch."

Check yourself

Why do dual writes (DB then index from the app) drift apart?

Answer: A crash between the two writes leaves them different, with nothing to repair it. There is no transaction across two systems; CDC or an outbox table makes one write the source.

What does polling with WHERE updated_at > last_run miss?

Answer: Deleted rows, because they are no longer there to select. A delete leaves no row behind. Soft deletes or CDC from the log are needed.

Where does a CDC tool like Debezium read changes from?

Answer: The database write-ahead log (or binlog). The log already records every committed change in order, so reading it adds little load and misses nothing.

See it happen in the simulation →

change data capturecdcdebeziumwrite-ahead logdual writeelasticsearch syncoutboxdata engineering

More in data platform