惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
Microsoft Azure Blog
Microsoft Azure Blog
MongoDB | Blog
MongoDB | Blog
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
O
OpenAI News
酷 壳 – CoolShell
酷 壳 – CoolShell
The GitHub Blog
The GitHub Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
博客园 - 聂微东
Engineering at Meta
Engineering at Meta
W
WeLiveSecurity
Hacker News: Ask HN
Hacker News: Ask HN
大猫的无限游戏
大猫的无限游戏
Vercel News
Vercel News
D
Docker
F
Full Disclosure
AI
AI
罗磊的独立博客
博客园 - 【当耐特】
U
Unit 42
S
SegmentFault 最新的问题
Stack Overflow Blog
Stack Overflow Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Palo Alto Networks Blog
博客园_首页
H
Help Net Security
量子位
月光博客
月光博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 司徒正美
F
Fortinet All Blogs
D
DataBreaches.Net
B
Blog RSS Feed
Webroot Blog
Webroot Blog
TaoSecurity Blog
TaoSecurity Blog
S
Secure Thoughts
爱范儿
爱范儿
I
InfoQ
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Attack and Defense Labs
Attack and Defense Labs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
C
CERT Recently Published Vulnerability Notes
Martin Fowler
Martin Fowler
Blog — PlanetScale
Blog — PlanetScale
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
Securelist

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Designing a Resilient Event-Driven Data Pipeline with Change Data Capture
Rizwan Saleem · 2026-06-04 · via DEV Community

Designing a Resilient Event-Driven Data Pipeline with Change Data Capture

Designing a Resilient Event-Driven Data Pipeline with Change Data Capture

In modern data platforms, near-real-time insights often hinge on how quickly and reliably changes in source systems propagate downstream. A well-architected event-driven data pipeline that uses Change Data Capture (CDC) can provide low-latency data updates, robust exactly-once semantics, and simple audit trails. This tutorial walks through a practical, maintainable design for an event-driven data pipeline built around CDC, streaming, and modular data processing services. It includes an actionable blueprint, recommended components, and example code to help you implement in production.

Overview of the problem and goals

  • Goal: Build a scalable data pipeline that captures changes from a relational source (or a set of sources), streams those changes to downstream consumers, and provides reliable processing guarantees, observability, and fault tolerance.
  • Constraints:
    • Low latency: minutes or seconds from source change to downstream availability.
    • Reliability: fault-tolerant with at-least-once or exactly-once semantics where feasible.
    • Observability: end-to-end visibility with tracing, metrics, and replay capability.
    • Modularity: clean separation between CDC capture, streaming backbone, and processing jobs.

High-level architecture

  • CDC capture layer: Detects changes in source databases and emits change records.
  • Streaming backbone: Publishes change events to a scalable log-based system.
  • Processing/services layer: Downstream services consume events, perform enrichment, materialization, and analytics.
  • Storage and sinks: Maintain durable stores for history, snapshots, and queryable views.
  • Observability and operations: Centralized logging, metrics, traces, and a workflow for schema evolution and replay.

Key components and rationale

  • Change Data Capture (CDC) source
    • Polling-based CDC or log-based CDC depending on database support.
    • Keeps track of a replication slot/offset or binary log position to ensure incremental changes.
  • Streaming platform
    • A durable, scalable log such as Apache Kafka, Kinesis, or Pulsar.
    • Provides partitioning, offset management, and replay capabilities.
  • Processing layer
    • Stream processors or microservices that subscribe to topics, apply business logic, and emit results to sinks.
    • Choose between stateful stream processing (for aggregation, windowing) or stateless microservices with idempotent behavior.
  • Sinks and materialized views
    • Data warehouses, data lakes, or operational databases to serve dashboards and BI.
    • Consider maintaining a changelog or upsert-capable sink to support replays and corrections.
  • Governance and schema evolution
    • Central schema registry and versioned schemas to handle evolving data models.
    • Backward/forward compatibility strategies and migration plans.
  • Operational primitives
    • Exactly-once or de-duplication mechanisms.
    • Retries, backpressure handling, and dead-letter queues for unprocessable events.
    • Monitoring, tracing, alerting, and runbook automation.

Detailed design and steps

1) Define the data domain and CDC strategy

  • Identify source systems: relational databases (PostgreSQL, MySQL), SaaS apps, or other data stores.
  • Decide on CDC approach:
    • Database log-based CDC (preferred for latency and fidelity) using tools like Debezium, Maxwell, or native CDC connectors.
    • Trigger-based polling if log access is unavailable, with a careful handling of, e.g., tombstones and deletes.
  • Model change events
    • Each event should include: operation type (insert/update/delete), primary key, before/after images (as applicable), timestamp, and a transaction/offset identifier for ordering.
    • Use a consistent envelope format, e.g.,:
    • type: "insert"/"update"/"delete"
    • database, table
    • primary_key: { ... }
    • before: { ... } or null
    • after: { ... } or null
    • ts: source timestamp
    • _offset: CDC offset or transaction id

2) Establish the streaming backbone

  • Choose a durable log: Kafka is a common default due to ecosystem, but Kinesis or Pulsar are valid alternatives depending on team constraints.
  • Topic layout
    • Per-table topics or a single topic with a table field, depending on cardinality and security requirements.
    • Use compacted topics for changelog-like views where appropriate.
  • Partitioning strategy
    • Partition by primary key hash to parallelize consumption while preserving in-order guarantees per key.
  • Exactly-once considerations
    • Use idempotent producers and transactional writes if your platform supports it (e.g., Kafka transactions).
    • Produce changelog events in a single, atomic batch where possible to reduce duplicates.

3) Processing layer design

  • Stateless microservices vs. stateful stream processors
    • Stateless services: simple enrichment, routing, and materialization to sinks.
    • Stateful processors: windowed aggregations, aggregations over keys, or joins with reference data.
  • Processing guarantees
    • Exactly-once: use transactional sinks and idempotent operations in the processing layer.
    • At-least-once with de-duplication: implement idempotency keys in downstream sinks and a dedupe window in the processor.
  • Processing patterns
    • Enrichment: join events with reference data (e.g., dimension tables) loaded into a fast store (Redis, in-memory databases) or materialized in a stream-table abstraction.
    • Materialization: write computed views to a sink (e.g., a data warehouse, a NoSQL store) for dashboards.
    • Error handling: route unprocessable events to a dead-letter topic for manual inspection.

4) Sinks and materialized views

  • Operational databases or search indexes
    • Used for serving queries with low latency; ensure you can handle upserts and deletes.
  • Data warehouse or lakehouse
    • For analytics and long-term retention; support incremental loads and schema evolution.
  • Data quality checks
    • Implement post-load validation with counters, row counts, and sampling to detect drift between source and sink.

5) Schema management and evolution

  • Use a centralized schema registry (e.g., Confluent Schema Registry) to manage Avro/JSON schemas.
  • Versioned schemas
    • Backward-compatible changes (adding fields with defaults) allow rolling updates without breaking producers/consumers.
    • Forward-compatible changes (removing fields) require careful handling and deprecation windows.
  • Migration plan
    • Deploy schema updates in a controlled sequence: producers first, then consumers, with feature flags to switch parsing logic.

6) Observability and operations

  • End-to-end tracing
    • Use distributed tracing (OpenTelemetry) to track events from source to sink.
  • Metrics
    • Track lag between CDC and processing, event throughput, error rates, and processing latency.
  • Logging and alerting
    • Centralize logs, set thresholds for lag, and alert on spikes or failures.
  • Replay and rollback
    • Be able to replay a range of events from a given offset if a bug is discovered or a data correction is needed.

7) Security, compliance, and data governance

  • Access control
    • Least privilege for producers and consumers; encrypt data in transit and at rest.
  • Data redaction and PII handling
    • Mask or tokenize sensitive fields where appropriate; apply field-level security in the processing layer.
  • Compliance
    • Maintain audit trails for changes, provide data lineage, and enforce data retention policies.

8) Operational workflow and recovery planning

  • Deployment
    • Use blue/green or canary deployments for critical components to minimize risk.
  • Failure modes
    • CDC source failure: implement retry/backoff with circuit breakers; fall back to a safe paused state.
    • Streaming failure: monitor consumer lag and partition health; automatically reassign partitions if needed.
    • Sink outages: implement buffering with backpressure and dead-letter queues.
  • Disaster recovery
    • Regularly back up important state stores; keep an immutable log of events for rehydration.

Practical implementation example

Scenario: A PostgreSQL database is the source, Kafka is the streaming backbone, and a downstream analytics service materializes a customer activity view into a data lake (S3) and a fast, queryable cache (Redis). We’ll outline a minimal, working example using popular open-source tools.

Stack

  • Source: PostgreSQL with Debezium for CDC
  • Stream: Apache Kafka
  • Processor: Kafka Streams (or Apache Flink) for enrichment and materialization
  • Sinks: Amazon S3 (lakehouse-like data lake) and Redis (fast lookup)
  • Schema: Avro with Confluent Schema Registry
  • Observability: OpenTelemetry, Prometheus, Grafana

Step-by-step guide

1) Set up CDC on PostgreSQL with Debezium

  • Enable logical replication on PostgreSQL and create a replication user.
  • Run Debezium CDC connector pointing to PostgreSQL, configured to produce change events to a Kafka topic, e.g., dbserver1.public.customer_changes.
  • Ensure the Debezium connector outputs a consistent envelope with fields like before and after, op, and ts.

2) Create a Kafka topic strategy

  • Topic: customer_changes
  • Partitions: based on customer_id modulo partitions
  • Retention: long enough to cover expected replay windows (e.g., 7 days) plus some headroom

3) Implement a Kafka Streams processing job

  • Read from customer_changes
  • Apply business logic: for example, compute a derived field like last_seen, and join with a static reference dataset (customer_segments) loaded from a small in-memory store or a compacted topic
  • Materialize a target topic: customer_view
  • Persist to sink
    • Write a parquet/gzipped files to S3 for analytics
    • Update Redis with a real-time view for fast lookups

Java/Scala snippet (simplified)

  • Kafka Streams topology outline (pseudo):

KStream source = builder.stream("customer_changes", Consumed.with(Serdes.String(), jsonSerde));

KTable segments = builder.table("customer_segments", Consumed.with(Serdes.String(), jsonSerde));

KStream enriched = source
.filter((k,v) -> v.get("op").asText() != "d") // filter deletes if desired
.join(segments, (change, seg) -> {
ObjectNode out = JsonNodeFactory.instance.objectNode();
out.set("after", change.get("after"));
out.set("segment", seg);
return out;
}, Joined.with(Serdes.String(), jsonSerde, jsonSerde))
.mapValues(v -> {
// compute derived fields
((ObjectNode) v).put("last_seen", System.currentTimeMillis());
return v;
});

enriched.to("customer_view", Produced.with(Serdes.String(), jsonSerde));

4) Materialize to S3

  • Use a sink connector or a small Spark job that reads customer_view from Kafka (or a parquet writer streaming) and writes daily/hourly partitions to S3 as parquet.
  • Ensure schema compatibility across writes; use a stable Avro schema for the parquet files.

5) Populate Redis for fast reads

  • A separate consumer subscribes to customer_view and writes the latest state for key customer_id into Redis:
    • Key: customer:
    • Value: JSON or a compact struct with essential fields
  • Implement a TTL if appropriate to avoid stale data; ensure eventual consistency with the lakehouse.

6) Observability

  • Instrument producers and consumers with OpenTelemetry traces that propagate through Kafka and the processing job.
  • Expose metrics like:
    • Ingested events per second
    • Processing latency
    • Lag between CDC and processing per partition
    • S3 write throughput and failure rate
  • Set up dashboards in Grafana for end-to-end visibility.

7) Handling schema evolution

  • Register both source and destination schemas in the registry.
  • Add fields with defaults for non-breaking changes.
  • When removing fields, phase them out with a deprecation period and update all producers/consumers in a controlled rollout.

8) Testing and validation

  • Unit tests for individual processing steps with mock input events.
  • End-to-end integration tests using a local CDC source and a test Kafka cluster.
  • Fuzz tests for schema changes and message drift.
  • Replay tests: store a known offset range and verify that reprocessing yields identical final state.

9) Security and governance

  • Use TLS for all connections; enforce authentication between components.
  • Limit access to Kafka topics with ACLs and to Redis/AWS resources with IAM roles.
  • Keep an audit log of CDC changes and data edits for compliance.

When to use this architecture

  • Real-time dashboards that need fresh data with low latency reports.
  • Scenarios requiring a single source of truth with a robust audit trail.
  • Environments where data quality and schema evolution must be managed rigorously.

Common pitfalls and how to avoid them

  • Pitfall: At-least-once processing causing duplicates.
    • Solution: Use idempotent sinks, deduplication windows, and transactional producers where supported.
  • Pitfall: Schema drift breaking downstream consumers.
    • Solution: Enforce backward-compatible schema changes and a strict release plan for schema evolution.
  • Pitfall: Lag growing unbounded under backpressure.
    • Solution: Implement backpressure-aware processing, auto-scaling, and robust DLQ handling.

Illustrative analogy

  • Think of CDC as a meticulous librarian watching a shelf for every book moved, added, or removed. The streaming backbone is the courier network delivering change cards in real time. The processing layer is a team of librarians who read each card, enrich it with context, and place it into a new, well-organized cabinet (the data lake or a cache) where analysts can retrieve up-to-date information quickly. Observability instruments act like a security camera and inventory system, ensuring we can trace every change from origin to its final resting place.

If you’d like, I can tailor this blueprint to your tech stack (e.g., AWS native services, Google Cloud, Azure, or a Kubernetes-based setup) and provide a more concrete code sample using your preferred language and tooling. Would you like a version aligned to a particular cloud provider or a pure open-source stack?

-

Rizwan Saleem | https://rizwansaleem.co