Data & Feature Engineering

Streaming vs Batch Data

Comparing scheduled bulk dataset processing against real time sub second continuous event streams.

🟡 intermediate5 min readdata
Streaming vs Batch Data processing represents the two core paradigms for ingestion and feature computation. Batch Data processing executes jobs on large historical datasets at scheduled intervals (nightly Spark jobs), offering high throughput and low cost at the expense of data freshness. Streaming Data processing ingests events continuously as they occur (Kafka and Flink), delivering sub second freshness for real time machine learning applications.

Two Data Processing Paradigms

Data pipelines feed machine learning models in one of two ways:

┌──────────────────────────┬──────────────────────────┐
│ BATCH DATA PROCESSING    │ STREAMING DATA PROCESSING│
├──────────────────────────┼──────────────────────────┤
│ Bounded historical data. │ Unbounded live events.   │
│ Scheduled intervals      │ Continuous processing    │
│ (Nightly Spark jobs).    │ (Kafka + Flink).         │
│ High throughput, 24h lag.│ Sub-second freshness!    │
└──────────────────────────┴──────────────────────────┘

1. Batch Data Processing

Accumulate incoming event logs into data lakes (S3) and process them in large scheduled bulk jobs:

2. Streaming Data Processing

Process individual event logs or micro-batches continuously as events occur in the real world:

Watermarks and Late Arriving Data

A major engineering challenge in stream processing is Out of Order & Late Arriving Data:

Real-world Event Occurs (Timestamp: 14:00:00) ──► Network Delay / Mobile Offline ──► Arrives at Flink (Timestamp: 14:15:00!)

Stream processors use Watermarks to define how long to wait for late arriving event data before closing time window aggregations.

The Lambda and Kappa Architectures

Say this out loud

Streaming vs Batch processing balances data freshness against system complexity and cost. Batch processing computes features over bounded historical data on scheduled cycles, providing high throughput at low cost. Streaming processing ingests unbounded event logs continuously using Kafka and Flink, delivering sub second feature freshness for real time prediction systems.

Followups to expect

  1. What is Sliding Window vs Tumbling Window in Flink? Tumbling windows divide time into non-overlapping fixed blocks (for example 5 minute blocks). Sliding windows overlap continuously (for example last 5 minutes updated every 10 seconds).
  2. How do you handle exactly once processing in streaming? Use distributed snapshot checkpointing (Chandy-Lamport algorithm in Flink) combined with idempotent writes to guarantee no event is counted twice.

Check yourself

Question 1 of 3

What primary trade off separates Streaming Data processing from Batch Data processing?

More in Data & Feature Engineering

See all →
Feature Engineering Fundamentals4 minSQL Questions in ML Interviews5 minEncoding Categorical Variables4 min