You can now use the new Onehouse PostgreSQL Change Data Capture (CDC) feature to stream data continuously into a data lakehouse. I will dive deep into the CDC architecture and pipelines using the Onehouse product which is built on open source systems such as Apache Kafka, Debezium and Apache Hudi.
To enable effective data-driven decision making, organizations recognize the need to leverage the wealth of data hosted within various OLTP databases. A solution that has gained popularity is replicating this data in near real-time to a data lakehouse, which serves as a powerful foundation for many critical use cases across industries.
Building a reliable and efficient data replication pipeline from RDBMS to a data lakehouse requires a comprehensive understanding of both the OLTP systems and the analytical requirements. It demands expertise in data integration, database technologies, data governance, and scalable architecture design. By successfully implementing such a solution, organizations can unlock the power of their high-value data, facilitate data-driven decision making, and unleash a wide array of critical use cases to drive business success.
By automating data management tasks and providing a fully managed, cloud-native platform, Onehouse allows customers to build data lakes quickly and easily, which can result in significant time and cost savings compared to a DIY approach. With Onehouse, customers can focus on deriving insights and value from their data. This can be particularly valuable for organizations that don't have the resources or expertise to design, build, and manage their own data infrastructure.
Onehouse also provides a range of enterprise security features, such as encryption, access controls, and monitoring, to ensure that data is protected at all times. This is essential for organizations that need to comply with industry regulations or data privacy laws. By using Onehouse, customers can have peace of mind that their data is secure and compliant.
Onehouse's modern architecture provides customers with full control over their own data and the compute resources used by the Onehouse data plane because the data plane is run within a customer's cloud account and VPC so that a customer’s data remains within their account and never leaves it. This is in contrast to some other SaaS cloud architectures, where data is processed and stored outside of the customer's account, often resulting in questions and concerns around data privacy and security. By using such an architecture, Onehouse is able to provide customers with the benefits of a cloud-based solution while allowing them to maintain the security and control of their data.
Relational database management systems (RDBMS) like PostgreSQL play a pivotal role in storing a significant portion of the world's valuable data. These databases primarily cater to online transaction processing (OLTP) systems, which are crucial for day-to-day business operations. However, running complex analytics directly on these OLTP databases such as PostgreSQL can be challenging as it may disrupt the high-volume transactional activities that are essential for smooth business functioning.
To address this challenge, it is critical to develop a change data capture (CDC) and replication framework, which orchestrates the movement of data from the OLTP databases to the data lake. This framework should be designed to handle complex data structures, maintain data consistency, minimize latency, and achieve near real-time synchronization. It must also account for the inherent challenges of replicating data from OLTP systems, such as concurrent updates, schema changes, and transactional dependencies.
Additionally, the architecture supporting the data lakehouse must be scalable, fault-tolerant, and optimized for analytical workloads. It should leverage distributed computing technologies and parallel processing capabilities to efficiently handle large datasets and complex analytics tasks. This enables organizations to derive valuable insights from the replicated data without impacting the operational efficiency of the OLTP databases.
Setting up a change data capture (CDC) streaming and replication to a data lake using PostgreSQL as a source involves multiple components. Let's break down the common components in a typical architecture:
Implementing a data pipeline using the components mentioned above is a complex task that requires a strong understanding of data engineering principles and experience in integrating and configuring the different tools. Data engineers need to have a deep understanding of each tool's capabilities, limitations, and integration points to ensure smooth interoperability and efficient processing. They also need to be familiar with best practices in data governance, security, and performance optimization to ensure the data pipeline is reliable, scalable, and cost-effective.
In addition, they need to be proficient in scripting and coding to automate tasks and reduce manual errors. Building a data pipeline using the mentioned components requires a combination of skills, knowledge, and experience in data engineering and related fields which would be hard to have for a customer.
As an example, let’s take a look at a common use case of performing CDC ingestion from a PostgreSQL database with 100+ tables to replicate data into the data lake.
Based on our experience, it typically takes three data engineers around three-six months to set up a pipeline of this nature. However, if you require the same data pipeline for four distinct business units, you would need to undertake the same laborious process four times, which could cost more precious engineering time. By leveraging Onehouse's Managed Lakehouse solution for the same use case, a single data engineer can productionize all four deployments in a couple weeks, resulting in a 10x or more cost savings. Moreover, apart from cost savings, this solution offers other intangible benefits, including simplified maintenance and quicker business insights.
Onehouse now has an exciting new feature that can perform CDC ingestion from a PostgreSQL to an analytics ready data lakehouse. Several customers such as Apna have been running this pipeline in production. Under the hood, Onehouse will automate the data infrastructure in your account to leverage Debezium, Kafka, Spark, and Hudi without exposing any of this complexity or maintenance to you. If you are currently designing your CDC ingestion pipelines to a data lake or if you are tired of the maintenance and on-call monitoring, Onehouse can make this a seamless experience for you.
In the following, I will go through an example that uses the Onehouse product to ingest data continuously from an AWS RDS PostgreSQL database into an Amazon S3 data lake.
To configure change data capture (CDC) on the source PostgreSQL database, you need to turn on logical replication using write ahead logging (WAL). For the details, see How do I replicate tables in RDS for PostgreSQL using logical replication and Setting up logical replication for your Aurora PostgreSQL DB cluster.
To verify the status of logical replication, log in to the source PostgreSQL database, and run the following query:
cdc_db=> SELECT name,setting FROM pg_settings WHERE name IN ('wal_level','rds.logical_replication');
name | setting
rds.logical_replication | on
wal_level | logical
To create a new PostgreSQL CDC source, log in to the Onehouse Management Console; go to Connections -> Sources and click “Add Data Source”. Choose “Postgres CDC”.
Onehouse will perform some network connectivity validation tests before a new source can be added.
In the Onehouse Management Console, on the left side, go to Services -> Capture and choose “Add a stream”. Give the new stream a name, choose the data source as the PostgreSQL CDC source created previously. Because we are working on a CDC use case, select the Write Mode as “Mutable (Updates/deletes)”.
For the test source table, specify the target table name and then click “Configure” and provide the information as shown below:
In the Transformations section, choose “Convert data from CDC format” and then click “Add Transform”; for CDC Format, pick “Postgres (Debezium)” as follows:
For this simple example, you may keep the other settings at their default values. In the final step, provide the target data lake, database and data catalog information:
That is it! You can now click “Start Capturing” and go back to Services -> Capture to confirm the new stream capture is starting up. It may take approximately 30-40 minutes for the initial setup because Onehouse needs to provision an Amazon MSK cluster and configure Debezium in the background. Following that all the incremental CDC streaming will be processed, transformed to the Hudi format and loaded into the data lake without any further delay.
Onehouse’s role does not stop there. Onehouse offers comprehensive data management and built-in support for Apache Hudi’s advanced table optimization services such as clustering, compaction, and cleaning. These services are critical for optimizing the performance and cost-effectiveness of Hudi tables, especially for these OLTP CDC and replication use cases, due to how fast the table data can be mutating.
Hudi’s industry leading and innovative async compaction feature is a game changer in the space of cloud data analytics. Compaction involves merging small files (Avro format) into larger base files (Parquet format) to reduce the number of files and improve query performance, without ever blocking writing.
With the data residing in the data lake that runs on Apache Hudi, customers have the flexibility to choose their preferred query engines, such as Amazon Athena, Apache Presto, Trino, Databricks or Snowflake, based on their specific requirements and cost/performance tradeoffs. By leveraging the Onetable feature, interoperable metadata can be easily generated for Delta Lake and Apache Iceberg, without the need to touch the underlying data.
In this blog post, we have demonstrated how simple it is to use the Onehouse PostgreSQL Change Data Capture (CDC) feature to set up an end-to-end data pipeline. By leveraging this feature, organizations can replicate data from their PostgreSQL databases to a data lakehouse with near real-time latency in just a few clicks! This enables them to keep up with the fast changing demands of the modern business world, where data-driven decision-making is essential for success.
I would like to thank my fellow Onehouse team members Vinish Reddy Pannala and Daniel Lee for their contributions to the Onehouse PostgreSQL CDC feature.
Be the first to read new posts