In this article, we discuss the necessity of segregate data model for read and write and use event sourcing for capture detailed data changing. These two aspects are critical for data analysis in big data world. We will compare some candidate solutions and draw a conclusion that CDC strategy is a perfect match for CQRS pattern.

Context and Problem

To support business decision-making, we demand fresh and accurate data that’s available where and when we need it, often in real-time.

But,

  • as business analysts try to run analysis, the production databases are (will be) overloaded;
  • some process details (transaction stream) valuable for analysis may have been overwritten;
  • OLTP data models may not be friendly to analysis purpose.

We hope to come out with a efficient solution to capture detailed transaction stream and ingest data to Hadoop for analysis.

CQRS and Event Sourcing Pattern

CQRS-based systems use separate read and write data models, each tailored to relevant tasks and often located in physically separate stores.

Event-sourcing: Instead of storing just the current state of the data in a domain, use an append-only store to record the full series of actions taken on that data. 

Decouple: one team of developers can focus on the complex domain model that is part of the write model, and another team can focus on the read model and the user interfaces.

Ingest Solutions - dual writes

Dual Write

  • brings complexity in business system
  • is less fault tolerant when backend message queue is blocked or under maintenance
  • suffers from race conditions and consistency problems

Business log

  • concerns of data sensitivity
  • brings complexity in business system

Ingest Solutions - database operations

Snapshot

  • data in the database is constantly changing, so the snapshot is already out-of-date by the time it’s loaded
  • even if you take a snapshot once a day, you still have one-day-old data in the downstream system
  • on a large database those snapshots and bulk loads can become very expensive

Data offload

  • brings operational complexity
  • is inability to meet low-latency requirements
  • can’t handle delete operations

Ingest Solutions - capture data change

process only “diff” of changes

  • write all your data to only one primary DB;
  • extract two things from that database:
  • a consistent snapshot and
  • a real-time stream of changes 

Benefits:

  • decouple with business system
  • get a latency of less than a second
  • stream is ordering of writes, less race conditions
  • pull strategy is robust to data corruption (log replaying)
  • support as many variant data consumers as required

Ingest Solutions - wrapup

Considering data application under the picture of business application, we will focus on the ‘capture changes to data’ components.

Open Source for Postgres to Kafka

Sqoop
can only take full snapshots of a database, and not capture an ongoing stream of changes. Also, transactional consistency of its snapshots is not wells supported (Apache).
pg_kafka
is a Kafka producer client in a Postgres function, so we could potentially produce to Kafka from a trigger. (MIT license)
bottledwater-pg
is a change data capture (CDC) specifically from PostgreSQL into Kafka (Apache License 2.0, from confluent inc.)
debezium-pg
is a change data capture for a variety of databases (Apache License 2.0, from redhat)

Debezium for Postgres is comparatively better.

Debezium for Postgres Architecture

debezium/postgres-decoderbufs

  • manually build the output plugin
  • change PG configuration, preload the lib file and restart PG service

debezium/debezium

  • compile and package the dependent jar files

Kafka connect

  • deploy distributed kafka connect service
  • start a debezium connector in Kafka connect

HBase connect

  • development work: implement a hbase connect for PG CDC events
  • Start a hbase connector in Kafka connect

Spark streaming

  • development work: implement data process functions atop Spark streaming

Considerations

Reliability
For example

  • be aware of data source exception or source relocation, and automatically/manually restart data capture tasks or redirect data source;
  • monitor data quality and latency;

Scalability

  • be aware of data source load pressure, and automatically/manually scale out data capture tasks;

Maintainability

  • GUI for system monitoring, data quality check, latency statistics etc.;
  • GUI for configuring data capture task scale out

Other CDC solutions

Databus (linkedIn): no native support for PG
Wormhole (facebook): not opensource
Sherpa (yahoo!) : not opensource
BottledWater (confluent): postgres Only (NOT maintained any more!!)
Maxwell: mysql Only
Debezium (redhat): good
Mongoriver: only for MongiDB
GoldenGate (Oracle): for Oracle and mysql, free but not opensource
Canal & otter (alibaba): for mysql world replication

Debezium for PostgreSQL to Kafka的更多相关文章

  1. kafka connect rest api

    1. 获取 Connect Worker 信息curl -s http://127.0.0.1:8083/ | jq lenmom@M1701:~/workspace/software/kafka_2 ...

  2. debezium关于cdc的使用(上)

    博文原址:debezium关于cdc的使用(上) 简介 debezium是一个为了捕获数据变更(cdc)的开源的分布式平台.启动并指向数据库,当其他应用对此数据库执行inserts.updates.d ...

  3. 基于Apache Hudi和Debezium构建CDC入湖管道

    从 Hudi v0.10.0 开始,我们很高兴地宣布推出适用于 Deltastreamer 的 Debezium 源,它提供从 Postgres 和 MySQL 数据库到数据湖的变更捕获数据 (CDC ...

  4. 几篇关于MySQL数据同步到Elasticsearch的文章---第一篇:Debezium实现Mysql到Elasticsearch高效实时同步

    文章转载自: https://mp.weixin.qq.com/s?__biz=MzI2NDY1MTA3OQ==&mid=2247484358&idx=1&sn=3a78347 ...

  5. Build an ETL Pipeline With Kafka Connect via JDBC Connectors

    This article is an in-depth tutorial for using Kafka to move data from PostgreSQL to Hadoop HDFS via ...

  6. Kafka设计解析(八)- Exactly Once语义与事务机制原理

    原创文章,首发自作者个人博客,转载请务必将下面这段话置于文章开头处. 本文转发自技术世界,原文链接 http://www.jasongj.com/kafka/transaction/ 写在前面的话 本 ...

  7. Kafka设计解析(八)Exactly Once语义与事务机制原理

    转载自 技术世界,原文链接 Kafka设计解析(八)- Exactly Once语义与事务机制原理 本文介绍了Kafka实现事务性的几个阶段——正好一次语义与原子操作.之后详细分析了Kafka事务机制 ...

  8. pg 资料大全1

    https://github.com/ty4z2008/Qix/blob/master/pg.md?from=timeline&isappinstalled=0 PostgreSQL(数据库) ...

  9. Awesome Go精选的Go框架,库和软件的精选清单.A curated list of awesome Go frameworks, libraries and software

    Awesome Go      financial support to Awesome Go A curated list of awesome Go frameworks, libraries a ...

随机推荐

  1. windows server 2008 远程桌面连接数修改--无限连接

    1.开启远程桌面 我的电脑 |  属性 |  远程设置  |  远程 |  进允许运行使用网络级别身份验证的远程桌面的计算机连接(更安全)(N)

  2. linux下nginx tomcat集群

    集群系统一般通过两台或多台节点服务器系统通过相应的硬件及软件互连,每个群集节点都是运行其自己进程的独立服务器. 这些进程可以彼此通信,对网络客户机来说就像是形成了一个单一系统,协同起来向用户提供应用程 ...

  3. Devexpress ChartControl 柱状图简单例子

    //using DevExpress.XtraEditors; //using DevExpress.XtraCharts; // Create an empty chart. ChartContro ...

  4. Codeforces 709B 模拟

    B. Checkpoints time limit per test:1 second memory limit per test:256 megabytes input:standard input ...

  5. OSGi 系列(三)之 bundle 事件监听

    OSGi 系列(三)之 bundle 事件监听 bundle 的事件监听是在 bundle 生命周期的不同状态相互转换时,OSGi 框架会发出各种不同的事件供事先注册好的事件监听器处理. 1. 事件监 ...

  6. shiro + struts2 在action 中使用 shiro 注解 @requiresPermissions 报错: 方法找不到,类初始失败

    06:36:34,405 ERROR http-8084-2 dispatcher.Dispatcher:38 - Exception occurred during processing reque ...

  7. classification report 使用

    别人写的,但是还是有些不清晰,我最后补上了 最后一行:第一个0.7=(0.5*1+0*1+1*3)/5  其他类似 support行:在真实数据中y_ture中class 0有一个 class 1有1 ...

  8. PHP 用 ZipArchive 打包指定文件到zip供用户下载

    Ubuntu需安装zlib sudo apt-get install ruby sudo apt-get install zlib1g zlib1g.dev   Windows需开启php_zip.d ...

  9. hdu-1026(bfs+优先队列)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1026 题意:输入n,m和一个n*m的矩阵, .表示通路: x表示墙: n表示有一个怪物,消灭它需要n个 ...

  10. Spring boot变量的初始化顺序

    起因是Spring建议”总是在您的bean中使用构造函数建立依赖注入.总是使用断言强制依赖”,而且之前用@Autowired时idea总是给警告,于是全部改成了构造器注入,运行时发生了循环注入,于是找 ...