Batch vs Stream Processing • Micro-batching TechniquesEasy⏱️ ~2 min
What is Micro-batching?
Definition
Micro-batching is a data processing pattern that groups streaming events into very small batches, typically every 1 to 10 seconds, then processes each batch as a miniature batch job rather than handling events individually.
Typical Latency Range
5-10s
P50 LATENCY
15-20s
P99 UNDER LOAD
💡 Key Takeaways
✓Micro-batching groups streaming events into small time windows (1 to 10 seconds) and processes them as discrete batch jobs
✓It provides near real-time latency (5 to 20 seconds) while keeping the simpler programming model and fault tolerance semantics of batch processing
✓Each micro-batch reads from source offsets, transforms data, writes to sinks, and checkpoints progress for deterministic replay on failure
✓Typical production systems achieve 7 to 8 second p50 latency and 15 to 20 second p99 latency with 5 second batch intervals
📌 Examples
1An ad platform processes 200,000 impression events per second by pulling from Kafka every 5 seconds (1 million events per batch), computing per-campaign aggregates, and writing to both a real-time dashboard store and a feature store for ML models
2A monitoring pipeline collects application logs every 3 seconds, aggregates error rates by service, and updates alert thresholds, providing dashboard updates with 5 to 8 second end-to-end latency
3A recommendation system recomputes user preference features every 10 seconds from click events, writing updated feature vectors to an online serving layer that feeds real-time models