Streaming is a type of data processing engine that is designed with infinite data sets in mind. Nothing more.
Unlike Batch processing where data is bounded with a start and an end in a job and the job finishes after processing that finite data, Streaming is meant for processing unbounded data coming in realtime continuously for days,months,years and forever. As such, being always meant for up and running, a streaming application is hard to implement and harder to maintain.
Important Aspects of Stream Processing:
- Delivery Guarantees
- Fault Tolerance
- _State Management
- Performance
- Advanced Features
Two Types of Stream Processing:
Now being aware of the terms we just discussed, it is now easy to understand that there are 2 approaches to implement a Streaming framework:
Native Streaming:
Also known as Native Streaming.It means every incoming record is processed as soon as it arrives, without waiting for others. There are some continuous running processes (which we call as operators/tasks/bolts depending upon the framework) which run for ever and every record passes through these processes to get processed. Examples : Storm, Flink, Kafka Streams, Samza.
Micro-batching :
Also known as Fast Batching. It means incoming records in every few seconds are batched together and then processed in a single mini batch with delay of few seconds. Examples: Spark Streaming, Storm-Trident.
How Stream Processing Works
The stream processing pipeline follows a systematic flow from data generation to actionable output
-
Data Collection - Data is continuously generated from multiple sources including IoT sensors, financial transactions, website analytics, social media platforms, application logs, and connected devices.
-
Data Ingestion - The incoming data flows immediately into the stream processing engine through message brokers like Apache Kafka without waiting for batches to accumulate.
-
Real-Time Processing - Each data element is processed immediately upon arrival through operations including filtering, transformation, aggregation, enrichment, and joining with other streams.
-
State Management - The engine maintains necessary state information to track aggregations, session data, and window information across events.
-
Output Generation - Processed results are published to downstream systems such as dashboards, databases, alert systems, or message queues.
| Aspect | Stream Processing | Batch Processing |
|---|---|---|
| Processing Model | Continuous, event-driven | Scheduled, periodic |
| Data Latency | Low (milliseconds-seconds) | High (hours-days) |
| Throughput | Continuous flow | Large discrete volumes |
| Complexity | Higher (state management) | Lower (simpler logic) |
| Cost | Higher (continuous resources) | Lower (scheduled resources) |
| Ideal For | Real-time analytics, monitoring | Historical analysis, reporting |
Stream Processing Architectures
- Lambda Architecture
- Kappa Architecture
Frameworks
| Framework | Latency | Throughput | State Mgmt | Languages | Exactly-Once | Complexity | Best For |
|---|---|---|---|---|---|---|---|
| Kafka Streams | Low | High | Good | Java | Yes | Low | Kafka-centric apps |
| Flink | Very Low | Very High | Excellent | Java/Scala/Python | Yes | High | Complex stateful processing |
| Storm | Very Low | Very High | Limited | Multiple | Limited | Medium | Low-latency analytics |
| Samza | Low | High | Good | Java/Scala | Yes | Medium | Kafka ecosystem |
| Kinesis | Low-Medium | High | Limited | Multiple | Limited | Low | AWS ecosystem |
| Dataflow | Low-Medium | High | Good | Java/Python | Yes | Medium | Google Cloud ecosystem |