When you start building an app, keeping your data consistent is easy. If a user changes something, your code updates the database, and you're done. But as your engineering team grows and you begin splitting a giant app into smaller, independent microservices, that simple approach breaks down.

If one service crashes or a network hiccup occurs, your services fall out of sync, and you end up chasing "ghost data."

Here is how you can move away from fragile database listeners and build a robust, central nervous system for your data using Apache Kafka and Change Data Capture (CDC).

The Problem: The Fragile Listener

In a basic setup, you might rely on your database to shout out notifications whenever data changes (like using PostgreSQL's LISTEN/NOTIFY feature). A small background script listens for these shouts and updates other systems—like clearing an old cache in Redis.