Mahdi.Kh
September 18, 2026
Using a CDC pipeline, we can transfer data from one machine to another in real time or near real time, without generating extra traffic on the database.
When working with databases, there are usually scenarios where a single database alone can't meet all our needs, or where using the database directly creates problems. Here are a few examples to better understand the potential issues:
When the primary database is used for application transactions, running heavy reporting or analytics on it at the same time causes slowdowns and heavy resource consumption. In this case, the data is moved to a different database, such as ClickHouse or Snowflake, that's suited to running data analysis queries.
Depending on each country's regulations, companies usually keep data for several months. For example, if your service is a messaging application and a user deletes a message, that message is kept in another database for a period of time, in accordance with regulations.
Even changes to data are collected, aggregated, and kept for a while. This data can be used to analyze user behavior and forecast the business's future.
In some architectures, such as microservices, our application is split into several smaller services, each with its own database, operating independently. In such cases, one of our services might need data that's stored in another service's database! One solution is to store and synchronize that data in both services — meaning ownership of the data (the right to add new data and edit it) belongs to one service, and the other service keeps a copy of that data, so that the load on the database of the service that owns the data doesn't increase.
Almost every large company monitors data changes in near real time. For example, by tracking the number of inserts/updates/deletes at any given moment, you can check how much load is on the database and react to changes in it. For instance, if the rate of deletes in a given time window doubles compared to that same window previously, it could indicate a security problem!
Or if the number of inserts (data being added to the database) changes drastically (for example, doubling), it could indicate a type of DDoS attack.
The primary database is usually designed for the application's day-to-day work (placing orders, user management, financial transactions, and so on), and when that same database is also used for other needs like reporting, analytics, or data transfer, we run into several serious problems.
| Potential Problem | Reason |
| High load on the primary database due to varied queries | Reporting and analytics queries are usually more complex and heavier than the regular queries used by the application. |
| Slower application transactions | As load on the database increases, the main application's queries may run more slowly, which slows down the application's performance. |
| Poor scalability / expensive scalability | Scaling the primary database is usually either impossible or comes with a lot of problems that increase our costs (time spent maintaining the database, plus money spent on infrastructure costs). |
| High risk to availability | Reporting and analytics queries are usually heavier, since a large amount of data needs to be examined and processed. In such cases, running a heavy query can crash the primary database and make it unavailable (go down). |
One of the best solutions to this problem is to use CDC. In CDC, instead of reading the entire database again (which requires a lot of time and cost), only the changes recorded in the database's log (such as the binlog in MySQL or the WAL in PostgreSQL) are extracted. These changes can later be sent to various systems — for example, Kafka or an MQ for processing, real-time Elasticsearch for fast search, or a data warehouse for data analysis.
This way, by using CDC, changes can be captured in real time or near real time and processed multiple times, without putting any load on the primary database.
To implement CDC, we need to enable the binlog. Then, depending on our needs, we can use available tools to capture changes to the database. Here, we'll look at two open-source tools.
Maxwell: source code + documentation
Both tools mentioned are open-source and free. But they have differences, which we'll go over below:
Maxwell needs simpler configuration, but it can only work with the binlog of a MySQL database. So if we want to capture changes for a database other than MySQL, we can't use Maxwell.
Debezium requires more configuration, but it can work with MySQL, PostgreSQL, MongoDB, and Oracle databases. So if you need to capture changes for a database other than MySQL, you can use Debezium.
So far, we've gotten familiar with CDC and how it works.
In the next part, as a real example, we'll run Maxwell on a MySQL database and send data changes to RabbitMQ, and finally record them in Typesense so they can be used by an application that performs fast search over the data. This way, we'll index the data on Typesense without putting any load on the primary database.