Batch vs Streaming: Beginner
What you will be able to do
Two Ways Data Can Move
Recognize the two processing rhythms, batch and streaming, and name what changes between them.
The Two Rhythms
| Rhythm | How Data Moves | What Drives the Cadence |
|---|---|---|
| Batch | Data sits in a source until a job runs and processes the accumulated chunk | A schedule (every hour, every night) or a manual trigger |
| Streaming | Each event flows through transforms as it arrives, one at a time or in tiny groups | The arrival of new data; the pipeline is always running |
| Hybrid (micro-batch) | Tiny scheduled batches that feel continuous from the outside | A short interval (every 10 seconds, every minute) the engine sets |
- ▸Batch waits and processes a chunk; streaming processes each event as it arrives
- ▸Batch runs sometimes; streaming runs always
- ▸Batch fails and restarts the chunk; streaming has to handle failure mid-flight
- ▸Batch optimizes for throughput; streaming optimizes for latency
An Everyday Analogy
- Chunks of data, processed when scheduled
- Reads everything that has accumulated, then sleeps
- Compute is cheap because the engine spins up and shuts down
- Freshness is bounded by the schedule (last hour, last day)
- Individual events, processed as they arrive
- Always running; never sleeps
- Compute is more expensive because nothing shuts down
- Freshness is bounded by the time to push one event through
The Smallest Possible Comparison
Most companies start with batch and add streaming only when a specific consumer cannot tolerate the wait. Streaming-first architectures are rare and almost always justified by a freshness requirement that batch literally cannot meet.
Two ways data moves: batch processes a whole chunk on a schedule (accurate, delayed); streaming processes each event as it arrives (fast, continuous). The latency SLA decides which.
Batch: Picture, Rhythm, Example
Walk through a batch pipeline run end to end and name the points at which compute starts, runs, and shuts down.
The Shape of a Batch Run
| Step | What Happens | Typical Duration |
|---|---|---|
| Wake up | Orchestrator triggers the job at the scheduled time | Seconds |
| Read | Job reads the input window (last hour, last day) from the source | Seconds to minutes depending on volume |
| Transform | Job applies cleaning, joins, aggregations to the chunk | Most of the run; minutes to hours at scale |
| Write | Job writes the output to a partition or table | Seconds to minutes |
| Shut down | Compute resources are released; the job ends | Seconds |
The Nightly Run
Why Batch Is Cheap
Common Batch Cadences
| Cadence | When It Fits | Typical Use |
|---|---|---|
| Daily (overnight) | Consumer reads the next morning; cost matters | Executive dashboards, financial reports, ML training data |
| Hourly | Consumer wants same-day freshness without paying for streaming | Operational dashboards, marketing reports, fraud retrospective |
| Every 15 minutes | Near-real-time feel without the streaming infrastructure cost | Quasi-live ad spend dashboards, customer support queues |
| Weekly or monthly | Data changes slowly; reading more often is wasted work | Cohort analyses, retention reports, long-horizon trends |
What Batch Cannot Do
- ▸The pipeline runs on a schedule and processes the chunk that has accumulated since the last run
- ▸The result is available some time after the run starts, bounded by how long the run takes
- ▸Compute is paid for only during the run; idle time is free
- Use batch as the default unless a specific consumer cannot wait for the next scheduled run
- Match the cadence to the consumer's freshness need; do not over-run if hourly is enough
- Partition outputs by the run window so failed runs replay one partition cleanly
- Reach for streaming because it sounds more modern; the cost difference is real
- Run a batch job continuously by scheduling it every minute; that is just expensive streaming
- Confuse a slow batch with a streaming need; profiling first beats redesigning later
Streaming: Picture, Rhythm, Example
Trace a single event through a streaming pipeline from source queue to output sink.
The Shape of a Streaming Pipeline
| Element | What It Does | What It Looks Like |
|---|---|---|
| Source | Produces events continuously into a queue or log | Kafka topic, Kinesis stream, Pub/Sub topic |
| Consumer process | Reads events as they arrive, applies transforms, emits results | Long-running JVM, Python service, Spark cluster |
| State store | Holds running totals, windows, joins between events | RocksDB on local disk, in-memory cache, external KV store |
| Output sink | Where transformed events land for downstream consumption | Another Kafka topic, a database, a feature store |
The Live Event Feed
Why Streaming Costs More
- Compute is on for the run, off the rest of the day
- Cost scales with the size of each chunk plus overhead per run
- Idle hours are free; ramp-up amortizes across the chunk
- A 1 percent traffic dip lowers cost the next night
- Compute is on every minute of every day
- Cost scales with provisioned capacity, not actual traffic
- Idle hours still cost the same as peak hours
- A 1 percent traffic dip lowers nothing; capacity is fixed
Common Streaming Use Cases
| Use Case | Why Streaming Fits | Tolerable Latency |
|---|---|---|
| Fraud detection | Decisions must happen before the transaction settles | Sub-second to a few seconds |
| Live operational dashboards | Operators react to events as they happen | Seconds to a minute |
| Real-time personalization | User session is short; recommendations must adapt within the session | A few hundred milliseconds |
| IoT telemetry | Volume is too high to batch economically; alarms are time-critical | Seconds to a minute |
| Change data capture (CDC) | Change data capture (CDC) turns each row write in an operational database into an event stream; downstream replicas must reflect upstream changes within seconds | Seconds to a few minutes |
What Streaming Is Not
- ▸Each event flows through the pipeline as it arrives, with no waiting for a scheduled run
- ▸End-to-end latency is bounded by the time to read, transform, and write one event
- ▸Compute is paid for around the clock; cost scales with provisioned capacity, not actual volume
What Real-Time Actually Means
Translate a real-time request into a concrete freshness tier and name the architecture each tier requires.
Five Freshness Tiers
| Tier | Freshness Target | Typical Architecture |
|---|---|---|
| Sub-second | Under 100 milliseconds end to end | Specialized streaming with co-located compute and storage |
| Near real-time | Under 15 minutes | Streaming or micro-batch (Spark Structured Streaming, Flink) |
| Same day | Under 2 hours | Hourly batch or micro-batch every 15 minutes |
| Daily | By the next morning | Nightly batch, runs at 2am, ready by 7am |
| Weekly or slower | On a calendar cadence | Weekly batch, often on a Sunday or Monday morning |
Why Real-Time Usually Means Tier 2 or 3
- ▸What decision will be made with this data, and how often does that decision happen?
- ▸How long can the consumer wait between event and action without harm?
- ▸What does the consumer do today when they cannot get this data?
- ▸Is the bound a hard SLA or a fuzzy preference?
The Cost of Misnaming the Tier
- Consumer needs sub-15-minute freshness; pipeline runs nightly
- Symptom: angry consumer, rebuilds shadow pipeline of their own
- Cost shows up as drift between two pipelines and reconciliation work
- Fix: upgrade to streaming or micro-batch for that one consumer
- Consumer needs daily freshness; pipeline runs streaming
- Symptom: a Flink cluster that costs $4,000 a month for a daily dashboard
- Cost shows up as a cloud bill nobody can explain
- Fix: replace streaming with a nightly batch; same numbers, 1/20th the cost
The Tier Conversation
Almost every real-time request that reaches a data engineer translates to tier 2 (under 15 minutes) or tier 3 (under 2 hours). Genuine tier 1 (sub-second) is rare and usually has a specific dollar value attached to the latency.
Picking Batch or Streaming
Pick batch or streaming for a simple use case based on the consumer's freshness tier and cost tolerance.
Case 1: A Marketing Team's Daily Signup Count
Case 2: A Fraud Team's Suspicious Transaction Alert
Case 3: An Ad Spend Dashboard That Updates Hourly
| Case | Tier | Right Choice |
|---|---|---|
| Daily signups dashboard | Tier 4 (daily) | Nightly batch; cheapest, simplest, fits the consumer |
| Fraud transaction alert | Tier 1 or 2 (seconds) | Streaming; the latency justifies the cost |
| Ad spend dashboard | Tier 3 (same day) | Hourly batch; balances freshness with cost |
The Three-Question Test
- ▸What decision is made with this data, and how often is that decision made?
- ▸How long can the consumer wait between event and answer without harm?
- ▸Does the consumer's tolerance match a tier 4 or 5 (batch) or a tier 1 or 2 (streaming)?
- Consumer reads on a schedule (morning standup, end-of-day report)
- Freshness tolerance is hours or days
- Cost per dollar of value matters more than latency
- Failure recovery means rerunning a clean partition
- Consumer reacts to events as they happen
- Freshness tolerance is seconds or single-digit minutes
- A late answer is worse than no answer
- Volume is high enough that buffering hours of data hurts
What This Means in Practice
- Default to batch and graduate to streaming for the specific consumers that need it
- Translate any real-time request into a numeric freshness tier before picking an architecture
- Name the cost difference explicitly so consumers can opt in or out of the tier they think they want
- Build streaming for everything because it sounds modern; the cost compounds
- Build batch for tier 1 needs because it is simpler; consumers will work around the pipeline
- Skip the freshness conversation; tools chosen without it are usually the wrong tools
> A media subscription company has three new dashboard requests in the same week. The CFO wants daily revenue at 7am Pacific. The growth team wants signup performance during a flash sale, updated within minutes. The product team wants weekly retention curves on Monday mornings. The data engineer is asked to design all three with a clear story for batch versus streaming.
Data moves in scheduled chunks or in a continuous flow; the choice changes everything downstream
- Category
- Pipeline Architecture
- Difficulty
- beginner
- Duration
- 25 minutes
- Challenges
- 0 hands-on challenges
Topics covered: Two Ways Data Can Move, Batch: Picture, Rhythm, Example, Streaming: Picture, Rhythm, Example, What Real-Time Actually Means, Picking Batch or Streaming
Lesson Sections
- Two Ways Data Can Move (concepts: paBatchVsStreaming)
Data moves through a pipeline in one of two basic rhythms. The first rhythm is scheduled. Data piles up for a while, then a job wakes up, processes everything that has accumulated since the last run, and goes back to sleep. The second rhythm is continuous. Each new event flows through the pipeline as it arrives, with no waiting for a scheduled wake-up. Almost every pipeline in production fits into one of these two rhythms, or a hybrid that explicitly mixes them. Naming the rhythm is the first us
- Batch: Picture, Rhythm, Example (concepts: paBatchProcessing)
Batch processing is the older of the two rhythms and still the dominant pattern in production. Most analytical work in most companies runs as a batch job, often nightly, sometimes hourly. The pattern is so common that the word pipeline used without qualification almost always means a batch pipeline. Knowing the shape of a batch run cold is the foundation for everything else, because streaming is largely defined by what it changes about that shape. The Shape of a Batch Run The Nightly Run The can
- Streaming: Picture, Rhythm, Example (concepts: paStreamProcessing)
Streaming processing is the second basic rhythm. A streaming pipeline runs continuously. Each new event arrives at the source and flows through the transforms within milliseconds or seconds. There is no concept of a chunk and no concept of a scheduled wake-up. The pipeline is a long-running service, more like a web server than a script. The shape is more recent than batch in mainstream use, dating roughly from the rise of Apache Kafka in the early 2010s and the stream processors that grew up aro
- What Real-Time Actually Means (concepts: paBatchVsStreaming)
Real-time is the most overloaded phrase in data engineering. A product manager asks for a real-time dashboard and means within an hour. A finance executive asks for real-time revenue and means by the start of the workday. A trading firm asks for real-time and means within five microseconds. The word is so elastic that it carries almost no information. The only useful response to a real-time request is to ask for the actual freshness target in concrete units of time, then translate that target in
- Picking Batch or Streaming (concepts: paBatchVsStreaming)
Vocabulary becomes useful when applied to a specific decision. The exercise below picks between batch and streaming for three small concrete cases. The cases are intentionally simple so the choice is visible. Real production decisions are messier, but the same questions apply: what does the consumer need, when do they need it, and what does each option cost. Case 1: A Marketing Team's Daily Signup Count The marketing team wants a chart of new signups by country, by day, for the trailing 30 days.