← Case studies rahmadiyan.my.id

Case study · Streaming data platform

Real-Time CDC → ClickHouse Streaming Platform

Replacing a fleet of Python change-data-capture consumers with a ClickHouse-native KafkaEngine design — cutting CDC CPU by ~96% while validating millions of rows with zero errors.

Redacted case study. Written at a national electronic-payments company; employer, product brands, hostnames and credentials are omitted. Metrics are real, measured figures from the project.

The problem

Real-time CDC from four source systems was handled by a fleet of Python consumers orchestrated on a scheduler. They worked, but the cost and failure modes were adding up:

The design

I moved ingestion and transformation inside ClickHouse, removing Python from the hot path entirely:

source → Debezium → Kafka/Redpanda → ClickHouse KafkaEngine raw table → 5 Materialized Views → ReplacingMergeTree targets

The five-MV fan-out splits each stream into a main upsert path plus delete-staging, batch-log, dead-letter, and type-error sinks — so bad records are quarantined, not dropped, and every message is accounted for. Two source families needed special handling: MySQL (epoch-millisecond timestamp conversion) and two MongoDB databases whose Debezium delete tombstones carry the key in different shapes, resolved per connector. MongoDB deletes — which KafkaEngine can't natively reconcile — are swept by a lightweight 5-minute reconciliation job against a pending-deletes table.

Proving it

463% → 18%
CDC CPU under real traffic (~96% reduction)
820K+
rows validated with zero errors
8,000/s
benchmarked throughput (peak 1.5M inserts/min)
3.09M
rows in a 117-min endurance run · 0 CDC errors

Resource

Under real Debezium traffic, CDC CPU fell from 463% to ~18%, with idle overhead only +0.4pp over baseline.

Correctness

A four-phase validation across 14 tables landed 820K+ rows with zero errors. A stress burst pushed 120K rows in 2m6s, peaking at 2.41 GiB — 32% of the node memory limit.

Throughput envelope

A benchmark campaign on a 3-node ReplicatedMergeTree cluster scaled cleanly to 8,000 rows/sec, roughly linear at ~26–37 CPU% per 1k rows/sec; the message broker never exceeded 1–2% CPU. I also quantified virtualization overhead — 244% CPU under a VM vs 91% bare-metal at the same load — to pick the deployment target.

Endurance

A 117-minute mixed-workload run (3 MongoDB + 1 MySQL) landed 3,097,441 rows with 0 CDC errors; every topic lag (MySQL peak 7,718 messages) drained back to zero by completion.

Reliability & operations

Stack

ClickHouse — KafkaEngine Materialized Views ReplacingMergeTree Kafka / Redpanda Debezium MongoDB MySQL PostgreSQL · Patroni Dagster