Q&A-14Walk me through how you decide between continuous streaming, micro-batch, and daily batch when designing an ingestion and transformation pipeline.
Answer
The rule I use: pick the coarsest cadence that still meets the tightest consumer SLA, then check that the latency budget actually closes. Finer cadence costs more in every dimension (24/7 headroom, state, operational surface) so streaming is something you pay for with a freshness requirement you can name out loud. If nobody can name the consumer that breaks at 60 seconds, you don't need streaming.
Three questions decide it.
- What's the tightest consumer SLA, and what breaks if you miss it? "The fraud decision must land before the card auth completes" (~200 ms) is streaming. "The dashboard refreshes hourly" is not.
- Is the transform per-record or global? Map/filter/enrich runs at any cadence. Dedup, sessionization, joins against a slowly-changing dimension, and global ranking want batch or micro-batch, because the shuffle is the cost, not the freshness.
- What's the sink's commit model? This often decides it before freshness does.
The latency budget is the artefact that settles arguments. End-to-end freshness = source commit + processing + sink commit, and the floor is set by the coarsest of those, not the fastest.
- Streaming with an exactly-once sink: the freshness floor is the checkpoint interval, not the per-record processing time. A Flink job with
execution.checkpointing.interval = 60swriting to Iceberg through a two-phase-commit sink cannot publish a record faster than ~60 s plus commit latency, however fast the operator is. Teams routinely build a "sub-second" pipeline and ship 60-second freshness because nobody looked at the checkpoint interval. - Micro-batch: floor = trigger interval + batch duration. With
trigger(processingTime="1 minute"), freshness is ≥ 60 s. If the batch takes 90 s you don't get 90 s freshness: you get unbounded lag, because the next trigger queues behind the running one. - Daily batch: floor = schedule time + runtime + upstream arrival. If upstream lands at 02:00 and the job starts at 01:00, you are processing yesterday's partition.
Write that sum down with real numbers and check it against the SLA. It usually eliminates one option immediately.
Failure modes and how I detect them.
| Paradigm | Failure mode | Detection |
|---|---|---|
| Streaming | Checkpoint timeout under a GC pause → restart from last checkpoint, replay window = checkpoint interval | lastCheckpointDuration approaching checkpointInterval; checkpoint size trend |
| Streaming | Unbounded keyed state (no TTL) → RocksDB disk fills, checkpoints slow to a crawl | checkpoint size growing monotonically; state-backend disk usage |
| Micro-batch | triggerExecution exceeds the trigger interval → lag grows without bound | Spark StreamingQueryProgress.durationMs.triggerExecution vs the trigger interval |
| Micro-batch | Small-file explosion: 1-minute triggers write 1,440 files/day/partition | file count per partition; compaction-job backlog |
| Daily batch | Skew: one partition runs 10× the median task | Spark stage task-duration histogram; max/median ratio |
| Daily batch | Late-arriving data silently dropped | row count per partition vs upstream source count |
Cost, illustrative. 100M events/day at ~1 KB each ≈ 100 GB/day uncompressed → ~1,150 events/s average, 10,000/s peak.
- Streaming must be sized for peak, not average: 3 × 4-vCPU workers at ~$0.19/hr on-demand ≈ $420/month, plus the log (MSK/Kinesis) and its storage. Call it $500–700/month, running whether or not traffic shows up.
- Daily batch: 10 spot workers at ~$0.06/hr = $0.60/hr; 12 minutes/day ≈ $0.12/day ≈ $4/month, scaling to zero between runs.
That gap is the whole argument. Streaming buys freshness at roughly 100× the compute cost, so the freshness requirement has to be real.
When not to use each. Don't stream if the SLA is 15 minutes: you're paying 24/7 headroom for nothing. Don't micro-batch if you need sub-second; the trigger interval is a hard floor. Don't daily-batch if consumers need intra-day correction (inventory, fraud, pricing): reprocessing a partition at 03:00 doesn't help at 14:00.
The hybrid I default to: decouple ingest cadence from transform cadence. Stream ingest into the lake with a short commit interval (Kafka → Iceberg, 1-minute commits) so raw data is fresh and replayable, then run transforms at whatever cadence the consumer needs: micro-batch for the hot path, daily for the heavy global joins. One source of truth, and you can move a transform between cadences without re-architecting ingest.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.