Case study · Streaming data 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.
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:
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.
Under real Debezium traffic, CDC CPU fell from 463% to ~18%, with idle overhead only +0.4pp over baseline.
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.
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.
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.