Data Pipeline Patterns: Batch, Streaming, and Event-Driven Architectures
Try This First
Test your knowledge before reading. Don't worry if you get it wrong — that's part of learning.
Key Insights
- Understand batch processing, stream processing, micro-batch, Lambda vs Kappa architectures, event-driven design with Kafka and CDC, and a decision framework for choosing the right pattern.
Batch Processing: The Workhorse of Data Engineering
Batch processing is the traditional approach to data processing where data is collected, stored, and processed in discrete chunks at scheduled intervals. It remains the most common pattern in data engineering due to its simplicity, reliability, and cost-effectiveness.
- When to use: Historical reporting, daily/weekly aggregations, backfills, scenarios where sub-second latency is not required.
- Common tools: Apache Spark, dbt (for SQL transformations), Airflow/Dagster/Prefect (for orchestration), Hive, Trino.
- Advantages: Simple to reason about, easy to reprocess/backfill, lower infrastructure costs, well-suited for large volumes.
- Limitations: Higher latency (minutes to hours), not suitable for real-time use cases, can be wasteful if processing only a few new records.
Batch pipelines typically follow an extract-load-transform (ELT) pattern: raw data lands in a staging area, then transformation jobs run on a schedule to clean, join, and aggregate data into analytics-ready tables.
Stream Processing: Real-Time Data in Motion
Stream processing handles data continuously as it arrives, with latencies measured in milliseconds to seconds. Every record is processed individually or in small micro-batches, enabling real-time analytics, alerting, and event-driven applications.
- When to use: Real-time dashboards, fraud detection, alerting, live personalization, monitoring and observability.
- Common tools: Apache Kafka (message broker), Apache Flink, Kafka Streams, Apache Spark Streaming, RisingWave.
- Advantages: Sub-second latency, natural fit for event-driven architectures, enables real-time decision making.
- Limitations: Higher operational complexity, state management is hard, exactly-once semantics are difficult to guarantee, typically more expensive per-record.
Stream processing requires careful handling of state (e.g., windowed aggregations), watermarks (handling late-arriving data), and checkpointing for fault tolerance.
Micro-Batch: The Middle Ground
Micro-batch processing straddles batch and streaming by processing data in small, frequent batches (e.g., every 5-60 seconds) rather than record-by-record. Apache Spark Streaming popularized this pattern with its micro-batch architecture, where each batch is a small Spark job.
- When to use: When you need near-real-time latency but want the simplicity and fault-tolerance of batch processing.
- Common tools: Spark Structured Streaming (micro-batch mode), Flink (can be configured for micro-batch).
- Trade-offs: Lower latency than traditional batch, but higher per-record overhead than true streaming due to batch job startup costs.
Lambda Architecture: Batch + Streaming
The Lambda architecture, proposed by Nathan Marz, runs batch and stream processing paths in parallel. The batch layer provides accurate, comprehensive results (eventually consistent), while the speed layer provides low-latency results. A serving layer merges outputs from both paths.
┌─────────────┐ ┌──────────────┐ │ Batch Path │────→│ Batch View │──┐ │ (Spark/SQL) │ │ (accurate) │ │ ┌──────────────┐ └─────────────┘ └──────────────┘ ├──→│ Serving Layer│→ query ┌─────────────┐ ┌──────────────┐ │ │ (merged) │ │ Stream Path │────→│ Speed View │──┘ └──────────────┘ │ (Flink) │ │ (low-latency)│ └─────────────┘ └──────────────┘
- Strengths: Balances accuracy and latency; the batch layer can re-process and correct speed-layer approximations.
- Weaknesses: Code complexity (maintaining two codebases), operational overhead, high infrastructure costs.
- Best for: Systems where both historical accuracy and real-time views are required — e.g., recommendation systems, fraud detection with periodic model retraining.
Kappa Architecture: Stream-Only Simplicity
The Kappa architecture, advocated by Jay Kreps (creator of Kafka), eliminates the separate batch layer. All data is treated as a stream, and the stream processor handles both real-time and historical reprocessing by replaying events from the event log.
┌──────────────┐ ┌──────────────┐ │ Event Log │────→│ Stream Proc │────→ query │ (Kafka) │ │ (Flink/SQL) │ └──────────────┘ └──────────────┘ │ ↑ └──── replay ────────┘
- Strengths: Single codebase, simpler operations, natural reprocessing by replaying the event log, lower infrastructure costs.
- Weaknesses: All state management is in-stream; complex windowed operations can be harder to implement; requires a durable, scalable event log.
- Best for: Organizations already using Kafka as their central data backbone; teams comfortable with stream processing.
Event-Driven Architecture and Change Data Capture
Event-driven architecture (EDA) is a pattern where services communicate by producing and consuming events asynchronously. In data engineering, this pattern is enabled by two key technologies: Apache Kafka (or similar message brokers) and Change Data Capture.
- Apache Kafka: A distributed event store and streaming platform. Producers write events to topics; consumers read from topics. Events are durable, ordered, and replayable. Kafka is the backbone of most modern event-driven data platforms.
- Change Data Capture (CDC): A technique that captures row-level changes (inserts, updates, deletes) from source databases in real time. Tools like Debezium sit on database transaction logs and emit change events to Kafka, enabling low-latency data synchronization without batch ETL jobs.
- Schema Registry: A companion service to Kafka that stores and enforces schemas (Avro, Protobuf, JSON Schema) for events. Producers and consumers agree on the schema, preventing data format mismatches and enabling schema evolution.
Choosing an Architecture: A Decision Framework
| Requirement | Batch | Micro-Batch | Streaming |
|---|---|---|---|
| Latency requirement | Minutes to hours | Seconds | Milliseconds |
| Data volume | Petabytes (cost-effective) | Terabytes | Up to terabytes (more expensive) |
| Complexity | Low | Medium | High |
| Reprocessing | Trivial (rerun job) | Easy (fast replay) | Requires event log replay |
| Operational cost | Lowest | Medium | Highest |
| Best for | Reporting, analytics, ML training data | Near-real-time dashboards, alerting | Real-time fraud, personalization, monitoring |
In practice, most modern data platforms are hybrid. They use batch for their core analytics and ML pipelines, streaming for real-time operational use cases, and micro-batch for the middle ground. The key is to start simple (batch) and add streaming where the latency requirements justify the complexity cost.
Article Metadata
Review with Spaced Repetition
Add this lesson's 7 flashcards to your SM-2 study queue. They will appear when due in the Study Queue.
Feynman Concept Cards
Master each building block: read the ELI5, explore the analogy, work the example, find your gaps, teach it back, build it.
Batch Processing is a concept in foundations. In simple terms, Batch Processing covers foundational knowledge in Data Engineering. This data engineering concept addresses key topics in the foundational knowledge in data engineering domain. Also known as: batch jo
Analogy
Example
Find Gaps
Explain Batch Processing as if teaching a colleague who is new to foundations. Cover: what it is, how it works, and why it matters.
Create
Create a diagram that demonstrates Batch Processing in a real-world foundations scenario. Walk through your design decisions.
Show solution
A diagram for Batch Processing should include: 1. The core components of batch processing 2. How they interact 3. Expected outcomes or outputs
DataOps is a concept in best practices. In simple terms, DataOps covers best practices in Data Engineering. This data engineering concept addresses key topics in the best practices in data engineering domain. Also known as: DataOps practices, data operation
Analogy
Example
Find Gaps
Explain DataOps as if teaching a colleague who is new to best practices. Cover: what it is, how it works, and why it matters.
Create
Create a checklist that demonstrates DataOps in a real-world best practices scenario. Walk through your design decisions.
Show solution
A checklist for DataOps should include: 1. The core components of dataops 2. How they interact 3. Expected outcomes or outputs
Lakehouse Architecture is a concept in architecture. In simple terms, The Lakehouse architecture, formalized by Armbrust et al. (2021), combines the flexibility of data lakes (cheap object storage, diverse data types) with the reliability of data warehouses (ACID transa
Analogy
Example
Find Gaps
Explain Lakehouse Architecture as if teaching a colleague who is new to architecture. Cover: what it is, how it works, and why it matters.
Create
Create a diagram that demonstrates Lakehouse Architecture in a real-world architecture scenario. Walk through your design decisions.
Show solution
A diagram for Lakehouse Architecture should include: 1. The core components of lakehouse architecture 2. How they interact 3. Expected outcomes or outputs
Infrastructure is a concept in specialized. In simple terms, A concept related to infrastructure
Analogy
Example
Find Gaps
Explain Infrastructure as if teaching a colleague who is new to specialized. Cover: what it is, how it works, and why it matters.
Create
Create a diagram that demonstrates Infrastructure in a real-world specialized scenario. Walk through your design decisions.
Show solution
A diagram for Infrastructure should include: 1. The core components of infrastructure 2. How they interact 3. Expected outcomes or outputs
Feynman Synthesis — Prove You Understand
1. The One-Pager
Explain this lesson's core idea to a smart 15-year-old. No jargon allowed.
2. The Gap Map
List 3 things you are still unsure about. Be specific.
Knowledge Check
Test your understanding of this lesson.
Flashcards
Space = flip · 1-4 = grade · Swipe on mobile