Data Engineering Reference/Data Engineering Foundations

Batch, Streaming & Architecture Patterns

Lambda vs Kappa vs medallion, when to batch vs stream, and the trade-offs Google/Databricks teams negotiate in platform design reviews.

3/5Overview: 30m

Batch vs streaming

DimensionBatchStreaming
LatencyMinutes to hoursSeconds to sub-second
CostCheaper per TB (amortized cluster)Higher infra + ops complexity
CorrectnessEasier to reason about fixed input setWatermarks, late data, state
ExamplesDaily aggregates, ML training setsFraud alerts, live dashboards

Most FAANG-scale platforms use both — not either/or.

Architecture patterns

Lambda architecture (historical)

  • Speed layer — stream processing for recent data
  • Batch layer — full recompute for correctness
  • Serving layer — merge views

Problem: two codepaths, high maintenance. Largely superseded but still appears in legacy systems.

Kappa architecture

  • One stream as source of truth; reprocess history by replaying the log
  • Requires durable log (Kafka) and idempotent sinks
  • Jay Kreps' argument: batch is a special case of stream (bounded input)

Medallion (lakehouse standard)

LayerContentsQuality
BronzeRaw ingest, append-onlyAs-is from source
SilverCleaned, deduped, conformed schemaValidated
GoldBusiness aggregates, martsConsumer-ready

Link to Databases (Object Storage & Data Lakes) for Parquet/Iceberg/Delta storage — here we focus on pipeline flow between layers.

Micro-batch (structured streaming)

Spark Structured Streaming default: process in small batch intervals (e.g., 1 min). Bridges batch ergonomics with near-real-time latency. Not true streaming but often sufficient.

When to pick what

RequirementPattern
T+1 reportingBatch (nightly Spark/dbt)
< 1 min freshnessMicro-batch or stream
< 5 s + complex joinsFlink or Spark streaming with state
Reprocess history after bugReplay from bronze/Kafka

AI pipeline boundary

AI Systems covers RAG ingestion, embedding pipelines, and vector indexes for LLM products. This track covers general batch/stream ETL — the same bronze→silver patterns feed ML feature stores but we don't duplicate embedding-specific design here.

Interview answer template

"We use medallion on S3/Delta: bronze append from Kafka, silver dedup and schema enforcement, gold dbt marts. Fraud uses a separate Flink job — sub-30s SLA can't wait for nightly batch."

Further Reading

Hands-On Tasks (Optional)

Pipeline design drills and whiteboard exercises — DAG sketches, partition plans, backfill strategies. Assumes Databases and SQL fundamentals are in place.

  • Choose batch vs stream for three features

    For: (1) daily revenue dashboard, (2) fraud alert within 30s, (3) search index update within 5 min — specify batch, micro-batch, or true streaming and justify latency vs complexity.

    15m