VAYULearn
Colour theme
Investigate a failure
VAYU Learn

Kafka & Streaming

The Real Cost of Streaming - When Kafka and Spark Are Wrong

Real-Time Streaming Costs Three to Five Times More Than Equivalent Batch Processing. Here Is How to Decide If That Cost Is Justified for…

Kafka & StreamingSpark & PySpark

Real-Time Streaming Costs Three to Five Times More Than Equivalent Batch Processing. Here Is How to Decide If That Cost Is Justified for Your Use Case.

Streaming isn’t expensive because Kafka or Spark are bad choices. It’s expensive when you pay for always-on infrastructure to deliver latency the business never actually needed.

TL;DR

  • Streaming infrastructure bills continuously — 24 hours a day — regardless of how much data actually needs processing at any given moment; batch bills only for the minutes it actually runs
  • A real side-by-side comparison for a moderate-volume pipeline typically shows streaming costing 3–5x more than an equivalent batch job at the same data volume, for the same eventual output
  • The only question that determines whether that premium is justified is whether the business action taken on the data changes meaningfully between “15 minutes old” and “15 seconds old” — most pipelines never actually answer this question before choosing streaming
  • Micro-batch (5–15 minute triggers) captures most of the perceived benefit of streaming at closer to batch cost, and is the right default for the large majority of “we need this in real-time” requests
  • Downgrading an over-provisioned streaming pipeline to batch or micro-batch, once measured against actual latency need, is one of the highest-leverage cost changes available to most data platforms

An earlier post in this series covered the operational trade-offs of streaming versus batch. This one puts a number on it.


A retail analytics team built a Kafka-to-Spark-Structured-Streaming pipeline to power a “live inventory” dashboard, because the product brief said “real-time visibility into stock levels.”
The infrastructure: a 3-broker Kafka cluster, a Spark Structured Streaming job running continuously with a 10-second micro-batch trigger, and a dedicated cluster sized for peak checkout traffic, running 24 hours a day.
Eight months in, someone asked how often the dashboard was actually being viewed. The answer: by warehouse staff, roughly six times a day, during shift-change stock checks.
Nobody had ever needed inventory numbers accurate to the second. A 10-minute staleness would have been completely invisible to how the dashboard was actually used.
The always-on Kafka cluster and continuously-running Spark job had been costing roughly four times what an hourly batch job — running for 12 minutes, 24 times a day, then shutting down — would have cost for the exact same eventual dashboard.

The Latency Nobody Actually Needed

The operational trade-offs of streaming versus batch — failure modes, debugging complexity, state management — were covered earlier in this series. This post is narrower and more concrete: what streaming infrastructure actually costs relative to batch for equivalent output, and the specific framework for deciding whether a given use case’s latency requirement justifies that cost.


Infrastructure Cost Comparison - Streaming vs Batch

What “Always On” Actually Bills

A streaming pipeline’s defining cost characteristic is that its infrastructure exists continuously, independent of how much data is actually flowing through it at any given moment. A Kafka cluster and a Spark Structured Streaming job both bill for every hour they’re provisioned — 720 hours a month — regardless of whether the underlying event volume during any given hour is high, low, or effectively zero.

A batch job billed by actual execution time pays only for the minutes it runs. The same monthly data volume, processed once an hour in a 12-minute batch job, bills roughly 288 minutes a month of compute — against 43,200 minutes for the always-on streaming equivalent.

A Real Worked Comparison

Workload: process ~2M events/day, moderate transformation complexity
Streaming (Kafka + Spark Structured Streaming, always-on):
Kafka cluster (3 brokers, moderate instance size): ~$650/month
Spark cluster (sized for peak, running continuously): ~$2,400/month
Total: ~$3,050/month
Batch (hourly Spark job, 12 min runtime per run):
Spark cluster (same peak sizing, running 12 min × 24/day):
~288 min/month × (equivalent hourly rate) ≈ $780/month
No dedicated Kafka cluster needed — direct read from source
or a lightweight queue: ~$100/month
Total: ~$880/month
Approximate cost ratio: streaming costs roughly 3.5x
the equivalent batch job, for the same eventual data freshness
requirement being over-served by several orders of magnitude
(10-second latency vs an actual need measured in hours)

These are illustrative, directional figures — actual numbers depend heavily on cloud provider, instance types, and region. The ratio, not the specific dollar amount, is the point: continuous infrastructure billed for idle time is the core mechanism by which streaming’s cost premium accumulates, and it accumulates whether or not the latency it provides is being used by anyone.


Calculating Whether Streaming Is Justified

The Business Question Behind the Technical One

The technical question — “can we build this as a streaming pipeline” — is almost always answerable yes. The question that actually determines whether streaming is the right choice is different: does the action taken on this data change meaningfully depending on whether it’s 15 seconds old or 15 minutes old?

For the inventory dashboard in the opening story, the honest answer was no — warehouse staff checking stock during a shift change were never going to make a different decision based on second-level freshness versus 10-minute freshness. The “real-time” requirement in the product brief had never been validated against actual usage.

A Decision Framework With Real Numbers

Step 1: What is the actual latency requirement, in the business's terms —
not "real-time," but a specific number of seconds/minutes/hours?
Step 2: What is the cost of being wrong by that margin?
Fraud detection: seconds of latency can mean a fraudulent
transaction completes before it's caught — high cost of delay
Inventory dashboard for shift-change checks: minutes or hours
of latency changes nothing about the decision made — near-zero
cost of delay
Personalization/recommendation refresh: usually tolerates
minutes to hours without any noticeable degradation
in the actual user experience
Step 3: Calculate the cost delta between streaming and batch
for the actual data volume (as shown above)
Step 4: Compare the cost delta against the cost of the latency
gap identified in Step 2. If the cost of being 10 minutes
stale is near-zero, and the cost delta for streaming is
$2,000+/month, the streaming architecture is not justified
by anything except an unvalidated assumption in a product brief.

This framework doesn’t produce a universal answer — fraud detection and inventory dashboards genuinely have different correct answers. It produces a forcing function that requires the actual latency requirement and its actual cost of being wrong to be stated in specific terms before an architecture decision gets made, rather than defaulting to “real-time” because it sounds more capable.


Hybrid Patterns That Reduce Cost

Micro-Batch as the Middle Ground

For the substantial majority of “we need this in real-time” requests, a micro-batch pattern — Spark Structured Streaming with a 5–15 minute trigger interval, or a scheduled job running on the same cadence — delivers freshness that’s indistinguishable in practice from true streaming for the actual use case, at a cost structure much closer to batch.

# True streaming — always-on, 10-second trigger
query = df.writeStream \
.trigger(processingTime="10 seconds") \
.start()

# Micro-batch — same code, dramatically different cost profile
query = df.writeStream \
.trigger(processingTime="10 minutes") \
.start()

The infrastructure cost difference between these two triggers, for the same Spark cluster, comes almost entirely from how much idle time the cluster spends waiting between micro-batches versus how continuously busy it stays — a 10-minute trigger with autoscaling that scales down between batches captures most of batch’s cost efficiency while retaining streaming’s architectural pattern for cases where that pattern is genuinely useful (state management, exactly-once semantics across the pipeline).

Streaming Only the Path That Needs It

Not every part of a pipeline needs the same latency treatment. A common and cost-effective pattern: stream only the specific path that has a genuine latency requirement (a fraud score feeding a real-time block/allow decision), and batch everything else feeding off the same underlying event stream (the same events, aggregated hourly for a reporting dashboard).

Event stream (Kafka)
├── Streaming path: fraud scoring (genuine sub-second need)
│ → always-on, small dedicated resources for this path only
│
└── Batch path: hourly aggregation for reporting dashboards
→ scheduled job, reads from the same Kafka topic
with a batch consumer, runs 5 min every hour

This avoids paying the always-on tax for every downstream consumer of an event stream just because one consumer genuinely needs low latency.


The Migration Path - Streaming to Batch

Signs You Over-Provisioned for Latency

- The dashboard/consumer built on the streaming pipeline is checked
by humans on a schedule (shift changes, daily standups, weekly reviews) —
not continuously watched in real time

- Nobody can name a specific decision that would change based on
the data being 10 minutes fresher

- The "real-time" requirement originated in a product brief or
stakeholder request that was never validated against actual
downstream usage patterns

- The pipeline has been running for months and the always-on
infrastructure cost has never been compared against
what a batch equivalent would cost

What the Downgrade Actually Looks Like

# Before: always-on streaming, 10-second trigger
streaming_query = df.writeStream \
.format("delta") \
.trigger(processingTime="10 seconds") \
.option("checkpointLocation", checkpoint_path) \
.start(output_path)

# After: scheduled batch job, runs hourly via Airflow, 12 min execution
# Same transformation logic — this is a scheduling change,
# not a rewrite of the pipeline's actual processing code
def hourly_batch_job():
df = spark.read.format("kafka") \
.option("kafka.bootstrap.servers", brokers) \
.option("subscribe", topic) \
.option("startingOffsets", get_last_processed_offset()) \
.load()

result = apply_same_transformation_logic(df)
result.write.format("delta").mode("append").save(output_path)
save_last_processed_offset(get_latest_offset())

The transformation logic itself typically doesn’t need to change in this migration — what changes is the execution model, from a continuously-running query to a scheduled job that reads what’s accumulated since its last run. The core cost saving comes entirely from the shift away from always-on infrastructure, not from any change to the actual processing.


The Streaming Cost Decision Checklist

Before building streaming infrastructure
□ The actual latency requirement is stated as a specific number,
not the word "real-time"
□ A specific business decision or action has been named that
changes meaningfully based on that latency requirement
□ The cost delta between streaming and batch/micro-batch has
been calculated for the actual expected data volume
□ Micro-batch (5-15 min trigger) has been explicitly considered
and ruled out with a stated reason, not skipped by default
For existing streaming pipelines
□ Downstream consumption pattern has been checked — is the data
actually consumed continuously, or checked on a human schedule?
□ Always-on infrastructure cost has been compared against what
a batch/micro-batch equivalent would cost, at least once
□ Only the specific paths with a genuine latency requirement
are running as true streaming — other consumers of the same
event source are batched separately where appropriate

Final Takeaway

Streaming infrastructure is not expensive because streaming is a poor technology choice — it’s expensive because it bills continuously for capacity that most use cases only need to draw on intermittently, and because “real-time” gets requested far more often than it gets validated against how the data is actually used downstream.

The framework here isn’t an argument against streaming. Fraud detection, real-time bidding, and genuinely latency-sensitive operational systems have a real, validated cost of delay that justifies the always-on premium. The framework is against choosing streaming by default, for a use case where nobody has actually named the decision that changes when the data goes from 15 minutes old to 15 seconds old.

📌 Core Principle

Streaming bills for capacity you might need at any given second. Batch bills for capacity you actually used.Pay the premium only when the second actually matters.

Next in Series

Building a Cost-Aware Data Platform

Individual pipeline and cluster cost decisions only go so far without the organizational structure to sustain them.

Next: the final piece of the cost engineering phase — tagging strategy for cost attribution across teams, chargeback models that make cost visible to the people actually making architecture decisions, cost monitoring dashboards, and budget alerts that catch cost creep before it becomes an eight-month surprise.