Processes data in scheduled batches. Used for training, feature backfill, reporting, and non-real-time predictions.
| Aspect | Batch Pipeline |
|---|---|
| Trigger | Time-based (hourly, daily, weekly) |
| Latency | Minutes to hours |
| Data Volume | Large (GB to TB per run) |
| Compute | Spark, Flink batch, MapReduce, Dask |
| Examples | Daily model training, weekly feature backfill, monthly churn report |
# Batch training pipeline (simplified)
Schedule: Daily at 2 AM
1. Load yesterday's feature data from Feature Store (offline)
2. Load ground truth labels from data warehouse
3. Drop NaN rows, validate schema
4. Train model with hyperparameters from previous best run
5. Evaluate on validation set
6. If metrics improve: register model in registry, trigger deployment
Processes data as it arrives with sub-second latency. Used for inference, feature computation, and immediate actions.
| Aspect | Real-Time Pipeline |
|---|---|
| Trigger | Event-driven (request, message) |
| Latency | Milliseconds to seconds |
| Data Volume | Small per event (KB), high throughput |
| Compute | Kafka Streams, Flink, Spark Streaming |
| Examples | Online inference, real-time fraud detection, live dashboards |
Processes data through both batch and speed layers, merging results in a serving layer.
# Lambda Architecture
All incoming data splits into two paths:
Batch Layer:
Data → Batch processing → Pre-computed views (serving layer)
(complete, accurate, high latency)
Speed Layer:
Data → Stream processing → Real-time views (serving layer)
(approximate, low latency)
Serving Layer merges batch + speed views for query
Pros: Combines accuracy of batch with timeliness of streaming. Cons: Code duplication between batch and speed layers.
Simplified: everything is a stream. Batch is treated as a special case of streaming with a larger window.
# Kappa Architecture
Data → Event Stream (Kafka) → Stream Processor → Serving Layer
No separate batch layer.
Batch jobs = stream processing with historical replay (reprocess from topic start)
Pros: Single codebase, simpler operations. Cons: Harder to handle large historical backfills efficiently.
| Use Case | Recommendation |
|---|---|
| Training models | Batch (offline) |
| Real-time fraud detection | Online (speed layer) |
| Daily reporting | Batch |
| Real-time dashboard with historical data | Lambda (batch for history + speed for live) |
| Simple streaming pipeline | Kappa |